From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02
03 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 Sum
04 {open braces start code blocks and must be matched with a close brace
05 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer total;
06
07 publicpublic is used to indicate unrestricted access (any other class can have access) Sum()
08 {open braces start code blocks and must be matched with a close brace
09 total=this assignment operator makes the left side equal to the right side0;
10 }close braces end code blocks and must match an earlier open brace
11
12 publicpublic is used to indicate unrestricted access (any other class can have access) Sum(intint is the type for whole numbers and it is short for integer initialTotal)
13 {open braces start code blocks and must be matched with a close brace
14 total=this assignment operator makes the left side equal to the right sideinitialTotal;
15 }close braces end code blocks and must match an earlier open brace
16
17 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value add(intint is the type for whole numbers and it is short for integer number)
18 {open braces start code blocks and must be matched with a close brace
19 total=this assignment operator makes the left side equal to the right sidetotal+adds two numbers together or concatenates Strings togethernumber;
20 }close braces end code blocks and must match an earlier open brace
21
22 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
23 {open braces start code blocks and must be matched with a close brace
24 returnreturn means to provide the result of the method and/or cease execution of the method immediately ""+adds two numbers together or concatenates Strings togethertotal;
25 }close braces end code blocks and must match an earlier open brace
26 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/Sum.java