How to store an array of pairs in Java?

前端 未结 9 1341
日久生厌
日久生厌 2020-12-15 06:51

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

        
9条回答
  •  萌比男神i
    2020-12-15 07:27

    The Map.Entry type that you are trying to use is just an interface, and can therefore not be instantiated. If you wanted to (mis)use internal types of Map, then the concrete Map.Entry implementation HashEntry would be an option.

    It is however a much better idea to implement you own Pair type. Or to use a Map instead of an array if that suits you needs.

提交回复
热议问题