I am trying to create a program in java which asks the user to enter a string, the number equivalent of the string is then given as the output. eg ABC(2), DEF(3), GHI(4), JKL(5), MNO(6), PQRS(7), TUV(8), WXYZ(9). my code is below. The problem is once the user inputs their string to be converted I get no output(and no errors). I was wondering if someone could have a look and give me some advice. what i am trying to do is turn the string that the user has entered into an array and then use a for loop with nested if statements to go through the array and whatever letter there is in [i] give the equavilent number. but the system.out isnt working?
import java.util.Scanner;
public class keyPad {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter a string:");
Scanner userInput = new Scanner(System.in);
String convertString = userInput.next();
int length = convertString.length();
String[] stringArray = new String[length];
for(int i=0; i<length; i++){
if(stringArray[i] == "a" || stringArray[i] == "b" || stringArray[i] == "c"){
System.out.println("1");
}
if(stringArray[i] == "d" || stringArray[i] == "e" || stringArray[i] == "f"){
System.out.print("2");
}
if(stringArray[i] == "g" || stringArray[i] == "h" || stringArray[i] == "i"){
System.out.print("3");
}
if(stringArray[i] == "j" || stringArray[i] == "k" || stringArray[i] == "l"){
System.out.print("4");
}
if(stringArray[i] == "m" || stringArray[i] == "n" || stringArray[i] == "o"){
System.out.print("5");
}
if(stringArray[i] == "p" || stringArray[i] == "q" || stringArray[i] == "r" || stringArray[i] == "s"){
System.out.print("6");
}
if(stringArray[i] == "t" || stringArray[i] == "u" || stringArray[i] == "v"){
System.out.print("7");
}
if(stringArray[i] == "w" || stringArray[i] == "x" || stringArray[i] == "y" || stringArray[i] == "z"){
System.out.print("8");
}
}
}
}