From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch11;
02
03 importimport means to make the classes and/or packages available in this program java.util.Scanner;
04
05 /**
06 * Greeting program. Standard output forfor is a looping structure for repeatedly executing a block of code a non-FANG console I/O program;
07 * user provides her name at a prompt.
08 */
09 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects YourNameHere {open braces start code blocks and must be matched with a close brace
10 /**
11 * The mainThe main method is the place where applications begin executing. program. Prompt user forfor is a looping structure for repeatedly executing a block of code her name and print a greeting
12 * forfor is a looping structure for repeatedly executing a block of code her.
13 *
14 * @paramthis is the Javadoc tag for documenting the purpose of parameters args command-line arguments; ignored by thisthis means the current object (the implicit parameter) program
15 */
16 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args) {open braces start code blocks and must be matched with a close brace
17 Scanner keyboard =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Scanner(System.in);
18 System.out.print("What is your name? ");
19 String userName =this assignment operator makes the left side equal to the right side keyboard.next();
20 System.out.println("Hello, " +adds two numbers together or concatenates Strings together userName +adds two numbers together or concatenates Strings together "!");
21 }close braces end code blocks and must match an earlier open brace
22 }close braces end code blocks and must match an earlier open brace
23
24 //Uploaded on Mon Mar 29 21:41:09 EDT 2010
|
Download/View scg/ch11/YourNameHere.java