I have written a program which gives me three arrays.A string array and two dole arrays.... But I want to save them in one thing(I don\'t know if it would be an array or matrix)
A nice generic solution:
public class Triple {
private final L first;
private final K second;
private final V third;
public Triple(L first, K second, V third) {
this.first = first;
this.second = second;
this.third = third;
}
public L getFirst() {
return this.first;
}
public K getSecond() {
return this.second;
}
public V getThird() {
return this.third;
}
}
Which can be implemented as such:
Triple myTriple = new Triple<>("Hello world", 42, 666);
But the real concept here is representing a point of data as an object in your code. If you have a set of data ("I have a string and two ints that mean something"), then you would want to encapsulate it under a single class.