This is a program that runs a Conways Game of Life simulation. The main method is here:
public static void main(String Args[]) {
int x = 0;
int y = 0;
boolean cellState[][] = new boolean[][]{};
boolean newCellState[][] = new boolean[][]{};
String answer;
Scanner input = new Scanner(System.in);
while (true) {
System.out.print("\n Type anything for next generation, 'new' for new grid, or 'stop' to end>> ");
answer = input.nextLine();
if (answer == "new") {
cellState = newCells(cellState);
} else if (answer == "stop") {
break;
} else {
System.out.println("Not an option yet");
}
}
}
No matter what answer is entered it will skip past the if statements and return to the beginning of the loop.
It has nothing to do with the actual contents of the statements as far as I can tell, but its might have to do with the boolean expressions.