ArrayList | Sololearn: Learn to code for FREE!



package; import java.util.ArrayList; import java.util.Collections; class cat { public static void main(String[] args) { ArrayList <String> a1=new ArrayList<>(); a1.add("Surya"); a1.add("vijay"); a1.add("Chaitu"); a1.add("NTR"); a1.add("venky"); ArrayList<String>a2=new ArrayList<>(); a2.add("malar"); a2.add("sam"); a2.add("jyo"); a2.add("tapsi"); a2.add("saipallavi"); a2.addAll(a1); Collections.sort(a2); System.out.println(a2); } } Getting output as error Can u plz suggest how to rectify it

5/10/2020 1:08:44 PM

Haritha Vuppula

3 Answers

New Answer


Hello Indian The code playground doesn't suppprt packages. Remove "package" then it should work.


tq Denise Roßberg i got the output!


Indian Your welcome :)