I am totally new to Java and I've started with some simple console applications.
This is my current application's code:
Scanner sc = new Scanner(System.in);
boolean ExitLoop = false;
ArrayList<Integer> IDs = new ArrayList<Integer>();
ArrayList<Double> averages = new ArrayList<Double>();
while(!ExitLoop)
{
System.out.println("StudentID: ");
IDs.add(sc.nextInt());
System.out.println("Average: ");
averages.add(sc.nextDouble());
System.out.println("Do you want to register another student? [y/n] ");
ExitLoop = (sc.next() == "n");
}
Sorry to ask such a silly question but I am really stuck in this, I hit "n" but the while loop does not stop, and keeps working. Have I done anything wrong? what should I do to finish the loop when user enters "n" meaning no?