|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04
05 /**
06 * All about my application.
07 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
08 */
09 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 ArrayReview
10 {open braces start code blocks and must be matched with a close brace
11 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)
12 {open braces start code blocks and must be matched with a close brace
13 //declaring an array of integers called numbers
14 intint is the type for whole numbers and it is short for integer[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 numbers;
15 //intialize the array to hold 10 numbers
16 numbers=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays10]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
17 //put the number 5 in the first position of the array
18 numbers[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side5;
19 numbers[brackets are typically used to declare, initialize and index (indicate which element of) arrays9]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right side15;
20 Wiki.out.println("The array has a capacity of "+adds two numbers together or concatenates Strings together numbers.length);
21 Wiki.out.println("Printing using standard for loop.");
22 //standard for loop
23 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.length; i++this is the increment operator, which increases the variable by 1)
24 {open braces start code blocks and must be matched with a close brace
25 Wiki.out.println("number["+adds two numbers together or concatenates Strings togetheri+adds two numbers together or concatenates Strings together"] is "+adds two numbers together or concatenates Strings togethernumbers[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
26 }close braces end code blocks and must match an earlier open brace
27 //backwards through the numbers
28 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 sidenumbers.length-1; i>=this evaluates to true if the left side is not less than the right side0; i--this is the decrement operator, which decreases the variable by 1)
29
30 Wiki.out.println("number["+adds two numbers together or concatenates Strings togetheri+adds two numbers together or concatenates Strings together"] is "+adds two numbers together or concatenates Strings togethernumbers[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
31
32 //backwards through every other number
33 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 sidenumbers.length-1; i>=this evaluates to true if the left side is not less than the right side0; i=this assignment operator makes the left side equal to the right sidei-2)//i-=2 is equivalent to i=i-2
34 {open braces start code blocks and must be matched with a close brace
35 Wiki.out.println("number["+adds two numbers together or concatenates Strings togetheri+adds two numbers together or concatenates Strings together"] is "+adds two numbers together or concatenates Strings togethernumbers[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
36 }close braces end code blocks and must match an earlier open brace
37 Wiki.out.println("Printing using enhanced for loop.");
38 //enhanced for loop
39 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;
40 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)
41 {open braces start code blocks and must be matched with a close brace
42 Wiki.out.println("number["+adds two numbers together or concatenates Strings togetheri+adds two numbers together or concatenates Strings together"] is "+adds two numbers together or concatenates Strings togethersingle);
43 i++this is the increment operator, which increases the variable by 1;
44 }close braces end code blocks and must match an earlier open brace
45 }close braces end code blocks and must match an earlier open brace
46 }close braces end code blocks and must match an earlier open brace
|