+ 2

I need program in java prints the names in alphabetical order do you find the program

l need help

12th Mar 2017, 3:51 PM
Samootay Almlaak
Samootay Almlaak - avatar
4 Respostas
+ 5
Add your names to a ArrayList. Then sort it with collections.sort and print it out with a for loop. I hope i have helped you :D Code: import java.util.ArrayList; import java.util.Collections; public class Program { public static void main(String[] args) { ArrayList<String> names = new ArrayList<String>(10); names.add("David"); names.add("Bin"); names.add("Alex"); names.add("Cena"); Collections.sort(names); // print all at once System.out.println(names); //or print each string once for(int i = 0;i < names.size();i++) { System.out.println(names.get(i)); } } }
12th Mar 2017, 5:38 PM
Simon Then
Simon Then - avatar
+ 2
No problem :D
14th Mar 2017, 3:00 PM
Simon Then
Simon Then - avatar
+ 1
l need help please
12th Mar 2017, 5:24 PM
Samootay Almlaak
Samootay Almlaak - avatar
+ 1
thanks Simon then
14th Mar 2017, 2:53 PM
Samootay Almlaak
Samootay Almlaak - avatar