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 fang2.core.Game;
04
05 importimport means to make the classes and/or packages available in this program java.util.ArrayList;
06
07 /**
08 * Demonstrate how an ArrayList prints using System.out.println.
09 */
10 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 PrintAnArrayList
11 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
12 /**
13 * ArrayList of Integer (we will put in some numbers and dodo is part of the do-while looping structure (post condition loop) things
14 * with them)
15 */
16 privateprivate is used to restrict access to the current class only ArrayList<Integer> theTable;
17
18 /**
19 * Create the ArrayList; print out some information about it
20 */
21 @Override
22 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
23 System.out.println("theTable = " +adds two numbers together or concatenates Strings together theTable);
24 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>();
25 System.out.println("theTable = " +adds two numbers together or concatenates Strings together theTable);
26 System.out.println("theTable.size() = " +adds two numbers together or concatenates Strings together theTable.size());
27 }close braces end code blocks and must match an earlier open brace
28 }close braces end code blocks and must match an earlier open brace
29
30 //Uploaded on Mon Mar 29 21:39:15 EDT 2010
|
Download/View scg/ch08/PrintAnArrayList.java