Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class descendin
- {
- public static void main(String[] args)
- {
- String [] name={"Kamu","Dia","dan","Aku"};
- String temp;
- System.out.println("//Sebelum Sorting");
- for (int i=0; i<name.length; i++)
- {
- System.out.println(" "+name[i]+" ");
- }
- for (int i=0; i<(name.length-1); i++)
- {
- for (int j=0; j<(name.length-1); j++)
- {
- if (name[j].compareTo(name[j+1])>0)
- {
- temp=name[j+1];
- name[j+1]=name[j];
- name[j]=temp;
- }
- }
- }
- System.out.println("//Sesudah Sorting");
- for (int i=name.length-1; i>=0; i--)
- {
- System.out.println(" "+name[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement