Open Dain1234 opened 1 year ago
package com.dain.logics;
public class Alphaorder { public static void main(String[] args) { String a[] = { "Banana", "Apple", "Mango", "Kaka", "Rambo" }; int len = a.length; for (int i = 0; i < len; i++) { for (int j = i + 1; j < len; j++) { if (a[i].compareTo(a[j]) > 0) { String temp = a[i]; a[i] = a[j]; a[j] = temp; } }
} for (int i = 0; i < len; i++) { System.out.println(a[i]); } }
}
package com.dain.logics;
public class Alphaorder { public static void main(String[] args) { String a[] = { "Banana", "Apple", "Mango", "Kaka", "Rambo" }; int len = a.length; for (int i = 0; i < len; i++) { for (int j = i + 1; j < len; j++) { if (a[i].compareTo(a[j]) > 0) { String temp = a[i]; a[i] = a[j]; a[j] = temp; } }
}