From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
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 SampleClassTest
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 SampleClass sample;
13 sample=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor SampleClass(10);
14 SampleClass sampleAnother;
15 sampleAnother=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor SampleClass(5);
16 System.out.println("sample is "+adds two numbers together or concatenates Strings togethersample);
17 System.out.println("sampleAnother is "+adds two numbers together or concatenates Strings togethersampleAnother);
18 sample.tick();
19 System.out.println("sample is "+adds two numbers together or concatenates Strings togethersample);
20 System.out.println("sampleAnother is "+adds two numbers together or concatenates Strings togethersampleAnother);
21 sample.tick();
22 System.out.println("sample is "+adds two numbers together or concatenates Strings togethersample);
23 System.out.println("sampleAnother is "+adds two numbers together or concatenates Strings togethersampleAnother);
24 sampleAnother.tick();
25 System.out.println("sample is "+adds two numbers together or concatenates Strings togethersample);
26 System.out.println("sampleAnother is "+adds two numbers together or concatenates Strings togethersampleAnother);
27 sample.tick();
28 sampleAnother.tick();
29 System.out.println("sample is "+adds two numbers together or concatenates Strings togethersample);
30 System.out.println("sampleAnother is "+adds two numbers together or concatenates Strings togethersampleAnother);
31 //happens automatically - System.out.println(sample.toString());
32 System.out.println(sample.getSomethingElse());
33 }close braces end code blocks and must match an earlier open brace
34 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/SampleClassTest.java