Facing Issue using Scanner Class in Java

geekysandeep

Oct 11th, 2021 04:25 AM

I was trying Scanner Class to take input from user in Java,

Now the problem is I am facing issue in execusion -

import java.util.Scanner;
public class a
{
public static void main()
{
    Scanner b = new Scanner(System.in);
    System.out.println("Enter the integer");
    int c = b.nextInt();
    System.out.println("Enter the string");
    String d = b.nextLine();
    System.out.println();
    System.out.println(" The integer you entered is" + a);
    System.out.println(" The string you entered is "+b);
    }
}

Can anyone help me to recify where I have done the mistake?

Thank you!

bobbyiliev

Oct 16th, 2021 10:51 PM

Hello,

What is the exact error that you are getting?

Also have you tried changing : public static void main() { to public static void main(String[] args) {?

Best,

Bobby