-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment112_.java
More file actions
45 lines (27 loc) · 973 Bytes
/
Assignment112_.java
File metadata and controls
45 lines (27 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package abhilash_Asignments;
import java.util.LinkedList;
/*"WAP in Methods of Linkedlist
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, pollFirst and pollLast" */
public class Assignment112_ {
public static void main(String[] args) {
LinkedList L1 = new LinkedList();
L1.add("A");
L1.add("B");
L1.add("C");
System.out.println(L1);
L1.addFirst("testing"); //AddFirst Method
System.out.println("AddFirst Method:- " + L1);
L1.addLast("Course");
System.out.println("AddLast Method:- " + L1);
System.out.println("GetFirst Method:- " + L1.getFirst());
System.out.println("GetLast Method:- " + L1.getLast());
L1.removeFirst();
System.out.println("RemoveFirst Method:- " + L1 );
L1.removeLast();
System.out.println("RemoveLast Method:- " + L1);
L1.pollFirst();
System.out.println("poleFirst Method :- " + L1);
L1.pollLast();
System.out.println("poleLast Method :- " + L1);
}
}