I am looking for something similar to C++'s cin.ignore()
function.
I am new to JAVA and I trying something like this
Scanner user_input = new Scanner(System.in) ;
int num1, num2 ;
System.out.print("\n Enter the two numbers : " +
"\n number 1 : ") ;
num1 = user_input.nextInt() ;
System.out.print("\n Number 2 : ") ;
num2 = user_input.nextInt() ;
After this line when I am trying to take a String
input from the user like this
String choice;
choice = user_input.nextLine() ;
It just ignores it continues to the next line.
I tried using InputStream.skip(long) ;
just before taking the String
input from the user. I read from here that is equivalent to C++'s cin.ignore()
What is the mistake that I am making?
Oh I included this too import java.io.InputStream;
EDIT : I was asking for whether I could use InputStream.skip()
here.