Example Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

A feature of the operating system.

Example Program

Programs can be written to use any type of file as input, but this chapter only discusses input with text files. Here is a program that reads input from the keyboard:

import java.util.Scanner;

class Echo
{
  public static void main ( String[] args )
  {
    Scanner scan = new Scanner( System.in );
    String line;

    System.out.println("Enter your input:");
    line = scan.nextLine();

    System.out.println( "You typed: " + line );
   }
}

Here is how the program ordinarily works:

C:/users/default/JavaLessons>java Echo

Enter your input:
This came from the keyboard
You typed: This came from the keyboard

D:/users/default/JavaLessons>

QUESTION 3:

How many lines of data does the program read?