1 thought on “How to Use Scanners In Java (Part 1)

  1. I've typed this:

    import java.util.Scanner;
    public class scannerinput {
            private static void main(String[] args) {
            Scanner input = new Scanner(System.in);
                System.out.print("enter integer ");
            int intValue = input.nextInt();
            System.out.println("you entered: " + intValue);
                System.out.print("enter double value ");
            double doubleValue = input.nextDouble();
            System.out.println("you entered: ");
                System.out.print("Enter a string without spaces ");
            String string = input.next();
            System.out.println("Yo entered the String " + string);

    And get the error message: 'class scannerinput is public, should be declared in a file named scannerinput.java'

    How do I get this fixed?

Leave a Reply

Your email address will not be published. Required fields are marked *