I don't know how to solve this,help me please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I don't know how to solve this,help me please

Fill in the blanks to add three items to the list, sort it, and print 2. List<Integer> list = new ArrayList<Integer>(); list. (4); list.add(2); .add(1); Collections. (list); System.out.println(list.get( ));

19th Jun 2017, 11:41 PM
Gabrielle Cristine
Gabrielle Cristine - avatar
6 Answers
+ 11
add list sort 1 First two are hopefully self explanatory. sort is a method you can use in Collections, it will sort the list into ascending order. Since its now sorted in ascending order the values are: {1, 2, 4} 2 is at the index of 1. get(index) is what the method is expecting. So, get(1)
19th Jun 2017, 11:57 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
List<Integer> list = new ArrayList<Integer>(); list.add(4); list.add(2); list.add(1); Collections.sort(list); System.out.println(list.get(1));
16th Dec 2018, 7:49 PM
Likhon
Likhon - avatar
+ 2
Here is the solution : add list sort 1
28th May 2018, 8:29 AM
Mohammadalaminsiam
Mohammadalaminsiam - avatar
+ 1
thanks,i've solved it by myself,but thanks anyway,we need explanation for those codes
20th Jun 2017, 12:38 AM
Gabrielle Cristine
Gabrielle Cristine - avatar
0
Try this may help you add list sort 1
18th Oct 2021, 3:23 AM
chanchal mittal
chanchal mittal - avatar
0
add list sort 1
1st Jan 2022, 12:22 PM
M.I.M.Aqueel
M.I.M.Aqueel - avatar