I need to sort list of strings in the alphabetical order:
List list = new ArrayList();
list.add(\"development\");
list.add(\"Development\");
li
import java.util.Arrays;
import java.util.Scanner;
public class Test3 {
public static void main(String[] args) {
String a;
String b;
try (Scanner scan = new Scanner(System.in)) {
a = scan.next();
b = scan.next();
}
boolean ret = isAnagram(a, b);
System.out.println((ret) ? "Anagrams" : "Not Anagrams");
}
static boolean isAnagram(String a, String b) {
int l1 = a.length();
int l2 = b.length();
boolean rat = false;
if (l1 <= 50) {
if (l1 == l2) {
char[] chars1 = a.toLowerCase().toCharArray();
char[] chars2 = b.toLowerCase().toCharArray();
Arrays.sort(chars1);
Arrays.sort(chars2);
String Ns1 = new String(chars1);
String Ns2 = new String(chars2);
if (Ns1.equals(Ns2)) {
rat = true;
}
}
}
return rat;
}
}