File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
collections/linkedlist/get-an-index-of-element-of-linkedlist Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,14 @@ public static void main(String[] args) {
26
26
System .out .println (linkedList );
27
27
28
28
// get first index of GoldSpot
29
- int index = linkedList .indexOf ("GoldSpot " ); // 2
29
+ int index = linkedList .indexOf ("DrPepper " ); // 1
30
30
31
- System .out .println ("\n Index of the GoldSpot in linkedList is: " + index );
31
+ System .out .println ("\n Index of the DrPepper in linkedList is: " + index );
32
+
33
+ // get first index of GoldSpot
34
+ int indexGS = linkedList .indexOf ("GoldSpot" ); // 2
35
+
36
+ System .out .println ("\n Index of the GoldSpot in linkedList is: " + indexGS );
32
37
33
38
// get first index of Moxie
34
39
int indexMoxie = linkedList .indexOf ("Moxie" ); // 5
Original file line number Diff line number Diff line change @@ -26,13 +26,18 @@ public static void main(String[] args) {
26
26
System .out .println (linkedList );
27
27
28
28
// get last index of GoldSpot
29
- int index = linkedList .lastIndexOf ("GoldSpot " ); // 6
29
+ int index = linkedList .lastIndexOf ("DrPepper " ); // 1
30
30
31
- System .out .println ("\n Index of the GoldSpot in linkedList is: " + index );
31
+ System .out .println ("\n Last index of the DrPepper in linkedList is: " + index );
32
+
33
+ // get last index of GoldSpot
34
+ int indexGS = linkedList .lastIndexOf ("GoldSpot" ); // 6
35
+
36
+ System .out .println ("\n Last index of the GoldSpot in linkedList is: " + indexGS );
32
37
33
38
// get last index of Moxie
34
39
int indexMoxie = linkedList .lastIndexOf ("Moxie" ); // 7
35
40
36
- System .out .println ("\n Index of the Moxie in linkedList is: " + indexMoxie );
41
+ System .out .println ("\n Last index of the Moxie in linkedList is: " + indexMoxie );
37
42
}
38
43
}
You can’t perform that action at this time.
0 commit comments