I was trying to do this :
int n = myScanner.nextInt();
for(int i=0;i<n;i++){
String str = myScanner.nextLine();
.
.
.
}
when i compiled it shows some errors java.util.Scanner.nextInt(Scanner.java:2117). initially i thought it is a problem of nextLine() so i used next() . then i found out if i add myScanner.nextLine() after taking input in n i.e
int n = myScanner.nextInt();
myScanner.nextLine();
Then it worked fine. I want to know why this happened?