I'm using on program that I need get input from console in java. here is a simple code only for showing you the problem. public class Main {
public static void main(String args[])
{
// Using Scanner for Getting Input from User
Scanner in = new Scanner(System.in);
String s = in.nextLine();
System.out.println("You entered string "+s);
int a = in.nextInt();
System.out.println("You entered integer "+a);
float b = in.nextFloat();
System.out.println("You entered float "+b);
System.out.println();
}
}
for input :
"stackOverFlow"
12
3.4
out put is : You entered string stackOverFlow You entered integer 12
and out put should be : You entered string stackOverFlow You entered integer 12 You entered float 3.4
what is the problem why the last line don't be read by scanner ?