+ 2
I need program in java prints the names in alphabetical order do you find the program
l need help
4 ответов
+ 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));
}
}
}
+ 2
No problem :D
+ 1
l need help please
+ 1
thanks Simon then