Storing number pairs in java

后端 未结 5 726
栀梦
栀梦 2021-01-17 11:54

How do I store a set of paired numbers in java? Do I use lists or arrays or maybe something else?

eg. [ (1,1) , (2,1) , (3,5)]

5条回答
  •  借酒劲吻你
    2021-01-17 12:40

    You can use the class Pair!

        import javafx.util.Pair;
    
        int x = 23;
        int y = 98;
    
        Pair pair1 = new Pair<>(6, 7);
        Pair  pair2 = new Pair<>(x, y);
    

    I hope this helps you!

提交回复
热议问题