From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch08;
02
03 importimport means to make the classes and/or packages available in this program java.util.ArrayList;
04
05 importimport means to make the classes and/or packages available in this program fang2.core.Game;
06
07 /** Demonstrate ArrayList.get(index). */
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 PrintAnArrayList4
09 extendsextends means to customize or extend the functionality of a class Game {open braces start code blocks and must be matched with a close brace
10 /** Table of numbers. Filled and printed. */
11 privateprivate is used to restrict access to the current class only ArrayList<Integer> theTable;
12
13 /**
14 * Create and fill theTable; print entries
15 */
16 @Override
17 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup() {open braces start code blocks and must be matched with a close brace
18 theTable =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ArrayList<Integer>();
19
20 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 side 0; i !=this is the not equals operator which evaluates to true if both sides are different 70; i =this assignment operator makes the left side equal to the right side i +adds two numbers together or concatenates Strings together 7) {open braces start code blocks and must be matched with a close brace
21 theTable.add(i);
22 }close braces end code blocks and must match an earlier open brace
23
24 System.out.println("<after>");
25 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 j =this assignment operator makes the left side equal to the right side 0; j !=this is the not equals operator which evaluates to true if both sides are different theTable.size(); ++this is the increment operator, which increases the variable by 1j) {open braces start code blocks and must be matched with a close brace
26 System.out.print(" " +adds two numbers together or concatenates Strings together theTable.get(j));
27 }close braces end code blocks and must match an earlier open brace
28 System.out.println();
29 }close braces end code blocks and must match an earlier open brace
30 }close braces end code blocks and must match an earlier open brace
31
32 //Uploaded on Mon Mar 29 21:41:54 EDT 2010
|
Download/View scg/ch08/PrintAnArrayList4.java