I have to compare an array entered by keyboard with an array that has the alphabet to be able to sort it. I want to know how to compare the first indexes of each String of my arrangement with the alphabet to later order it.
I have to compare an array entered by keyboard with an array that has the alphabet to be able to sort it. I want to know how to compare the first indexes of each String of my arrangement with the alphabet to later order it.
To select the character of a String, and compare it you can do the following.
public class Ejemplo {
public static void main(String[] args) {
String ejemplo = "abcdefg";
String ejemplo2 = "acbshdj";
System.out.println(ejemplo.charAt(0));
if (ejemplo.charAt(0)==ejemplo2.charAt(0)) {
System.out.println("Son iguales");
}
}
}
I hope you solve the doubt