3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.7.publicstaticvoidmain(String[]args){8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);11.}12.}哪一行插入到第9行将导致输出abc”?()A.for(Objecto:list)B.for(Iteratoro:list)C.for(Objecto:list.iterator())D.for(Iteratoro:list.iterator();o.hasNext();)
3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.7.publicstaticvoidmain(String[]args){8.list.add("a");list.add("b");list.add("c");9.//insertcodehere10.System.out.print(o);11.}12.}哪一行插入到第9行将导致输出abc”?()
A.for(Objecto:list)
B.for(Iteratoro:list)
C.for(Objecto:list.iterator())
D.for(Iteratoro:list.iterator();o.hasNext();)
相关考题:
现有:3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.publicstaticvoidmain(String[]args){7.8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);}}哪一行插入到第9行将导致输出abc”?()A.for(Objecto:list)B.for(Iteratoro:list)C.for(Objecto:list.iterator())D.for(Iteratoro:list.iterator();o.hasNext();)
现有:3.importjava.util.*;4.classForInTest{5.staticListlist=newArrayList();6.7.publicstaticvoidmain(String[]args){8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);11.}12.}哪一行插入到第9行将导致输出abc”?()A.for(Objecto:list)B.for(Iteratoro:list)C.for(Objecto:list.iterator())D.for(Iteratoro:list.iterator();o.hasNext();)
importjava.util.*;publicclassLetterASort{publicstaticvoidmain(String[]args){ArrayListstrings=newArrayList();strings.add(?aAaA”);strings.add(”AaA”);strings.add(?aAa”);strings.add(”AAaa”);Collections.sort(strings);for(Strings:strings){System.out.print(s+);}}}Whatistheresult?()A.Compilationfails.B.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.Anexceptionisthrownatruntime.
importjava.util.*;2.publicclassTest{3.publicstaticvoidmain(String[]args){4.Liststrings=newArrayList();5.//insertcodehere6.}7.}Whichfour,insertedatline5,willallowcompilationtosucceed?() A.Strings=strings.get(0);B.Iteratori1=strings.iterator();C.String[]array1=strings.toArray();D.Iteratori2=strings.iterator();E.String[]array2=strings.toArray(newString[1]);F.Iteratori3=strings.iterator();
importjava.util.*;publicclassNameList{privateListnames=newArrayList();publicsynchronizedvoidadd(Stringname){names.add(name);}publicsynchronizedvoidprintAll(){for(inti=0;iSystem.out.print(names.get(i)+);}}publicstaticvoidmain(String[]args){finalNameListsl=newNameList();for(inti=0;i2;i++){newThread(){publicvoidruin(){sl.add(”A”);sl.add(”B”);sl.add(”C”);sl.printAll();}}.start();}}}Whichtwostatementsaretrueifthisclassiscompiledandrun?()
定义一个List对象list,使用ArrayList的构造方法进行初始化,并且要求list中必须全部存放Integer类型的对象,以下语句正确的是()。A.List list = new ArrayList<Integer>();B.List list = new ArrayList ();C.List<Integer> list = new ArrayList<Integer>();D.ArrayList<Integer> list = new List<Integer>();
创建一个只能存放String的泛型ArrayList的语句是哪项?()A.ArrayList<int> al=new ArrayList<int>();B.ArrayList<String> al=new ArrayList<String>();C.ArrayList al=new ArrayList();D.ArrayList al =new List();
创建一个只能存放String的泛型ArrayList的语句是哪项?A.ArrayList<String> al=new ArrayList<>();B.ArrayList al=new ArrayList<>();C.ArrayList al=new ArrayList();D.ArrayList al=new List();
若要创建用于存储整数的列表,请使用A.ArrayList<Object> list = new ArrayList<>();B.ArrayList<Integer> list = new ArrayList<>();C.ArrayList<int> list = new ArrayList<int>();D.ArrayList<Number> list = new ArrayList<>();