From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.util.*;
04 importimport means to make the classes and/or packages available in this program java.io.*;
05 //end auto-imports
06
07 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 SampleClass
08 {open braces start code blocks and must be matched with a close brace
09 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer count;
10 privateprivate is used to restrict access to the current class only Scanner file;
11
12 publicpublic is used to indicate unrestricted access (any other class can have access) SampleClass(intint is the type for whole numbers and it is short for integer startingCount)
13 {open braces start code blocks and must be matched with a close brace
14 count=this assignment operator makes the left side equal to the right sidestartingCount;
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 tick()
18 {open braces start code blocks and must be matched with a close brace
19 count++this is the increment operator, which increases the variable by 1;
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 "Count: "+adds two numbers together or concatenates Strings togethercount;
25 }close braces end code blocks and must match an earlier open brace
26
27 publicpublic is used to indicate unrestricted access (any other class can have access) String getSomethingElse()
28 {open braces start code blocks and must be matched with a close brace
29 returnreturn means to provide the result of the method and/or cease execution of the method immediately "Something else";
30 }close braces end code blocks and must match an earlier open brace
31 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/SampleClass.java