From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate.multiple;
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 number;
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 number=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) voidvoid means the method does not return a value add(intint is the type for whole numbers and it is short for integer number)
13 {open braces start code blocks and must be matched with a close brace
14 thisthis means the current object (the implicit parameter).number+=this increases the variable on the left by the value on the rightnumber;
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 reset()
18 {open braces start code blocks and must be matched with a close brace
19 number=this assignment operator makes the left side equal to the right side0;
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) intint is the type for whole numbers and it is short for integer getValue()
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 number;
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/multiple/Sum.java