Question: Cant figure out whats wrong with this very simple code? public class worker { public static void main(String[] args){ //read in the file into string
Cant figure out whats wrong with this very simple code?
public class worker {
public static void main(String[] args){
//read in the file into string array of words
String[] commands = {"a","b","c"};
for(int i = 0; i<= commands.length; i++){
if (commands[i] == "a") {
System.out.print(commands[i]);
}
else if (commands[i] == "b") {
System.out.print(commands[i]);
}
else if (commands[i] == "c") {
System.out.print(commands[i]);
}
else{
System.out.print("none of these was found!");
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
