Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Integer 型の ArrayList があります。値を int にキャストせずに値 (例: 1.25) を格納することはできますか?
ArrayList<Integer>いいえ、精度を落とさずにdouble を格納することはできません。ただし、それらを に保存することはできますArrayList<Double>。
ArrayList<Integer>
ArrayList<Double>
ArrayList<Number>代わりに使用してください。このようにして、両方のクラスがクラスから派生するため、Doubleとインスタンスの両方を格納できます。IntegerNumber
ArrayList<Number>
Double
Integer
Number