import java.util.Scanner; public class RandomTest {
public static void main(String[] args) {
    Scanner input=new Scanner(System.in);
    String[] alphabets={"a","b"};
    String [] cipher={"b","c"};
    System.out.println("Please enter a letter.");
                String word=input.nextLine();
    for (int i=0;i<2;i++){
        if (word.equals(alphabets[i])){
            System.out.println("Preparing a cipher");
            System.out.println("Here is the cipher: "+cipher[i]);
            }
    }
}
}
This code above works perfectly fine, but instead of saying (word.equals(alphabets[i])), if i put word==alphabets[i] it wouldn't work at all. While using the later, the program does not check if the input is equal to a value in the array. Why does this happen? 
 
    