Hello, I would like to know how I can obtain which word appears first in the dictionary, from two words that a user enters in java. Thank you very much. For example, if the user enters the word hola
and the word adiós
, what would be the method to know which of the 2 appears first in the diccionario
.
private static Scanner sc;
private static String pidePalabra1() {
System.out.print("Introduzca una palabra: ");
return sc.nextLine();
}
private static String pidePalabra2() {
System.out.print("Introduzca otra palabra");
return sc.nextLine();
}
private static void muestraInfo(String palabra1, String palabra2) {
System.out.printf("Palabra1: %s \tPalbra2: %s = %s")
}
public static void main(String[] args) {
sc = new Scanner (System.in);
String palabra1 = pidePalabra1();
String palabra2 = pidePalabra2();
muestraInfo (palabra1, palabra2);
}
}