I have been trying to create a program and right now I have trouble with the Scanner in java because in the program the user can input a String and press enter to input it and if the user inputs "exit" like so then the Scanner will close and The loop stops, but It just works for the first Input and gives out a black line every time and if you do enter exit it writes out exit but continues.
here is a code snippit:
public static void main(String[] args) {
int i = 0;
Scanner input = new Scanner(System.in);
while(input.hasNext() && i<1){
System.out.println(input.nextLine());
if(input.nextLine() == "exit"){
i++;
}
}
input.close();
}