Is this valid Java code: List<int> nums = new ArrayList<>();单项选择题
A
Yes
B
No, since List and ArrayList types don't match up.
C
No, since 'new ArrayList<>();' should instead be 'new ArrayList<int>();'
D
No, because list elements cannot be of primitive type
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
Which statement will compile and create a StudentIDs object given the following code: public class StudentIDs<TheType extends Comparable<TheType>> { private TheType item1; private TheType item2; public StudentIDs(TheType i1, TheType i2) { item1 = i1; item2 = i2; } } 1: StudentIDs<Integer> newStudent = new StudentIDs<Integer>(9, 5); 2: StudentIDs<int> newStudent = new StudentIDs<int>(9, 5); 3: StudentIDs<Integer> newStudent = new StudentIDs<>(9, 5); 4: StudentIDs<int> newStudent = new StudentIDs<int>(9, 5);
Which statement correctly creates an ArrayList of Integers?
Which of the following types can be used with Java generics?
What is the main goal of using generics in Java?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!