//********************************************************************
// Echo.java Author: Lewis/Loftus
// Taken from the book: Java, Software Solutions
//
// Demonstrates the use of the nextLine method of the Scanner class
// to read a string from the user.
//********************************************************************
import java.util.Scanner;
public class Echo
{
//-----------------------------------------------------------------
// Reads a character string from the user and prints it.
//-----------------------------------------------------------------
public static void main (String[] args)
{
String message;
Scanner scan = new Scanner (System.in);
System.out.println ("Enter a line of text:");
message = scan.nextLine();
System.out.println ("You entered: \"" + message + "\"");
}
}
/* Sample Compilation and Output:
C:\craig\public_html\cs111b>javac Echo.java
C:\craig\public_html\cs111b>java Echo
Enter a line of text:
Let me talk to you
You entered: "Let me talk to you"
C:\craig\public_html\cs111b>
*/
syntax highlighted by Code2HTML, v. 0.9