From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02
03
04 /**
05 * All about my application.
06 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
07 */
08 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 SumTest
09 {open braces start code blocks and must be matched with a close brace
10 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)
11 {open braces start code blocks and must be matched with a close brace
12 Sum sum;
13 sum=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sum();
14 Sum sum2;
15 sum2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sum();
16 sum.add(4);
17 sum2.add(7);
18 System.out.println("Sum is "+adds two numbers together or concatenates Strings togethersum);
19 System.out.println("Sum2 is "+adds two numbers together or concatenates Strings togethersum2);
20 sum.add(6);
21 System.out.println("Sum is "+adds two numbers together or concatenates Strings togethersum);
22 System.out.println("Sum2 is "+adds two numbers together or concatenates Strings togethersum2);
23 }close braces end code blocks and must match an earlier open brace
24 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/SumTest.java