how to compare a the first index of the strings of an array with another array in java

-3

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.

    
asked by Flambo 05.09.2018 в 20:28
source

1 answer

0

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

    
answered by 06.09.2018 в 03:43