Source Code

ScannerExample.java

// import all the classes and interfaces from the java.util package into your program.
import java.util.*;

public class ScannerExample {
    public static void main(String[] args) {
        System.out.println("Scanner Example Code");

        // 1. Print a message to the user
        

        // 2. Initialize the Scanner. Declare a variable named in
        // that reads from System.in
        

        // 3. Create a variable and assign it to the value returned by nextLine
        // The Scanner class provides a method called nextLine that reads a
        // line of input from the keyboard and returns a String.
        

        // 4. Print the value of the variable
        
        
        // 5. Close the Scanner
        

    }
}

ScannerExample2.java

M1Assignment.java

Last updated