I have a text file with thousands of lines of data like the following:
38.48,88.25
48.20,98.11
100.24,181.39
83.01,97.33
I can separate each "double" value just fine, but I'm having trouble adding each line to my user-defined class. In my main method, I created a list by:
List<Pair> data = new ArrayList<Pair>();
Where Pair is defined as:
class Pair {
private final double first;
private final double second;
public Pair(double first, double second) {
this.first = first;
this.second = second;
}
Now I'm trying to add items to this list. I tried: "data.add(double, double)" but that doesn't work. I tried creating a set method within the Pair class but it won't let me since "first" and "second" are declared as "final". I know I could just change them but I do want them to be final values. So how do I add an item to this list?