I am new to Java, I want to store an array of pair of doubles. My code looks like this:
import java.util.ArrayList;
import java.util.Map.Entry;
List
Create your own class to represent a pair and add a constructor that takes two arguments:
public class MyPair
{
private final Double key;
private final Double value;
public MyPair(Double aKey, Double aValue)
{
key = aKey;
value = aValue;
}
public Double key() { return key; }
public Double value() { return value; }
}
See this answer for reasons why a Pair does not exist in Java: What is the equivalent of the C++ Pair