From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program com.sun.org.apache.bcel.internal.generic.*;
04 //end auto-imports
05
06
07 /**
08 * All about my helper classclass is a group of fields and methods used for making objects.
09 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
10 */
11 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 LinkListImplementation
12 {open braces start code blocks and must be matched with a close brace
13 privateprivate is used to restrict access to the current class only LinkedListNode head;
14 privateprivate is used to restrict access to the current class only LinkedListNode tail;
15
16 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addFirst(String data)
17 {open braces start code blocks and must be matched with a close brace
18 ifif executes the next statement only if the condition in parenthesis evaluates to true(head==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
19 {open braces start code blocks and must be matched with a close brace
20 LinkedListNode node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedListNode(data, nullnull is the value used to refer to a non-existant object, nullnull is the value used to refer to a non-existant object);
21 head=this assignment operator makes the left side equal to the right sidenode;
22 tail=this assignment operator makes the left side equal to the right sidenode;
23 }close braces end code blocks and must match an earlier open brace
24 elseelse is what happens when the if condition is false
25 {open braces start code blocks and must be matched with a close brace
26 LinkedListNode node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedListNode(data, head, nullnull is the value used to refer to a non-existant object);
27 head.prev=this assignment operator makes the left side equal to the right sidenode;
28 head=this assignment operator makes the left side equal to the right sidenode;
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 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addLast(String data)
33 {open braces start code blocks and must be matched with a close brace
34 ifif executes the next statement only if the condition in parenthesis evaluates to true(head==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
35 {open braces start code blocks and must be matched with a close brace
36 LinkedListNode node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedListNode(data, nullnull is the value used to refer to a non-existant object, nullnull is the value used to refer to a non-existant object);
37 head=this assignment operator makes the left side equal to the right sidenode;
38 tail=this assignment operator makes the left side equal to the right sidenode;
39 }close braces end code blocks and must match an earlier open brace
40 elseelse is what happens when the if condition is false
41 {open braces start code blocks and must be matched with a close brace
42 LinkedListNode node=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedListNode(data, nullnull is the value used to refer to a non-existant object, tail);
43 tail.next=this assignment operator makes the left side equal to the right sidenode;
44 tail=this assignment operator makes the left side equal to the right sidenode;
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
47
48 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
49 {open braces start code blocks and must be matched with a close brace
50 LinkedListNode current=this assignment operator makes the left side equal to the right sidehead;
51 String total=this assignment operator makes the left side equal to the right side"head<->";
52 whilewhile is a looping structure for executing code repeatedly(current!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object)
53 {open braces start code blocks and must be matched with a close brace
54 total+=this increases the variable on the left by the value on the rightcurrent.data+adds two numbers together or concatenates Strings together"<->";
55 current=this assignment operator makes the left side equal to the right sidecurrent.next;
56 }close braces end code blocks and must match an earlier open brace
57 total+=this increases the variable on the left by the value on the right"tail";
58 returnreturn means to provide the result of the method and/or cease execution of the method immediately total;
59 }close braces end code blocks and must match an earlier open brace
60
61 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/LinkListImplementation.java