From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
02 importimport means to make the classes and/or packages available in this program java.util.*;
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 /**
05 * All about my application here.
06 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
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 WrapperExample
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 ArrayList<String> words;//declaring
13 words=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ArrayList<String>();//initializing
14 words.add("Jam");//filling
15 words.add("Jenkins");
16 forfor is a looping structure for repeatedly executing a block of code(String single: words)//iterating over 1.5+ style
17 {open braces start code blocks and must be matched with a close brace
18 Wiki.out.println(single);
19 }close braces end code blocks and must match an earlier open brace
20
21 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<words.size(); i++this is the increment operator, which increases the variable by 1)//iterating over 1.4 style
22 {open braces start code blocks and must be matched with a close brace
23 Wiki.out.println(words.get(i));
24 }close braces end code blocks and must match an earlier open brace
25
26 ArrayList<Integer> numbers;//declaring
27 numbers=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ArrayList<Integer>();//initializing
28 numbers.add(4);//filling
29 //numbers.add(new Integer(4));//actually does this automatically - auto-boxing
30 numbers.add(5);
31 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer single: numbers)//iterating over 1.5+ style - auto-unboxing
32 {open braces start code blocks and must be matched with a close brace
33 Wiki.out.println(single);
34 }close braces end code blocks and must match an earlier open brace
35
36 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<numbers.size(); i++this is the increment operator, which increases the variable by 1)//iterating over 1.4 style
37 {open braces start code blocks and must be matched with a close brace
38 Wiki.out.println(numbers.get(i));
39 }close braces end code blocks and must match an earlier open brace
40 }close braces end code blocks and must match an earlier open brace
41 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/WrapperExample.java