long-integer

Initialize ArrayList<Long>

旧巷老猫 提交于 2020-12-02 10:46:18
问题 Why I can initialize ArrayList, like this: ArrayList<Integer> x = new ArrayList<Integer>(Arrays.asList(1,2)); But got Error when using: ArrayList<Long> x = new ArrayList<Long>(Arrays.asList(1,2)); 回答1: Explanation Java automatically transforms int to long if needed. However, Java does not do the same if a transformation from Integer to Long is needed. The function Arrays.asList(...) returns a List<E> with E being the type used as parameters. As you use 1, 2, 3 the type is int . However the

Initialize ArrayList<Long>

China☆狼群 提交于 2020-12-02 10:43:23
问题 Why I can initialize ArrayList, like this: ArrayList<Integer> x = new ArrayList<Integer>(Arrays.asList(1,2)); But got Error when using: ArrayList<Long> x = new ArrayList<Long>(Arrays.asList(1,2)); 回答1: Explanation Java automatically transforms int to long if needed. However, Java does not do the same if a transformation from Integer to Long is needed. The function Arrays.asList(...) returns a List<E> with E being the type used as parameters. As you use 1, 2, 3 the type is int . However the

What is the Python equivalent of C types float, double and long?

感情迁移 提交于 2020-08-11 03:23:40
问题 What is the Python equivalent of these C types: float double long I want to represent a float in the above three forms. 回答1: I believe you mean types , not functions. In C, a double is just a double-precision float (meaning smaller numbers are represented more accurately). In Python, it's just a float . Similarly, a long is (was) just an int that stored larger numbers. In Python 2, there is int , long , and float . However, Python automatically promotes int to long when it grows above sys