From ggc
|
01 importimport means to make the classes and/or packages available in this program java.util.*;
02 /**
03 * All about my application here.
04 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
05 */
06 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 RandomGreeting
07 {open braces start code blocks and must be matched with a close brace
08 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)
09 {open braces start code blocks and must be matched with a close brace
10 Random random=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Random();
11 intint is the type for whole numbers and it is short for integer x=this assignment operator makes the left side equal to the right siderandom.nextInt(10)+adds two numbers together or concatenates Strings together1;
12 System.out.println("The number is "+adds two numbers together or concatenates Strings togetherx);
13 /*
14 ifif executes the next statement only if the condition in parenthesis evaluates to true(Math.random()>0.95)
15 System.out.println("World Hello!");
16 elseelse is what happens when the if condition is false
17 System.out.println("Hello World!");*/
18 }close braces end code blocks and must match an earlier open brace
19 }close braces end code blocks and must match an earlier open brace
|
Download/View RandomGreeting.java