I am just try to get a input as float but, I got an error. Please, help me to fix it.
This is my code
import java.util.Scanner;
public class {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
// Input
int a = in.nextInt(); // Integer
String b = in.nextLine(); // String
Float c = in.nextFloat(); // Float
// Output
System.out.println("Given integer :"+a);
System.out.println("Given string :"+b);
System.out.println("Given Float :"+c);
}
}
This is Output
2
stack
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextFloat(Scanner.java:2345)
at Main.main(Main.java:9)