Possible Duplicate:
java.util.Scanner : why my nextLine() in my code not promt?
import java.util.Scanner;
class apples {
public static void main(String args[]){
Scanner npwn = new Scanner(System.in);
int first,second,answer;
String op;
System.out.print("Insert first number: ");
first = npwn.nextInt();
System.out.print("Insert Operation ('+', '-', '*', '/')");
op = npwn.nextLine();
if (op.equals("+")) {
System.out.print("Insert next number: ");
second = npwn.nextInt();
answer = first + second;
}
else { System.out.print("Insert next number: ");
second = npwn.nextInt();
answer = first - second;
}
System.out.println(answer);
}
}
Where it says "op:nextLine();"; it doesn't pause and wait for the "nextLine" persay. It just skips and prints "Insert next number: ". Why is this?