-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinked.java
More file actions
27 lines (23 loc) · 779 Bytes
/
Linked.java
File metadata and controls
27 lines (23 loc) · 779 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
package practicetime;
import java.util.*;
public class Linked
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
/* Linked List Declaration */
LinkedList<Integer> linkedlist = new LinkedList<Integer>();
System.out.println(" Enter the Numbers ");
/*add(String Element) is used for adding
* the elements to the linked list*/
for(int i=0;i<5;i++)
{
linkedlist.add(s.nextInt());
}
/*Display Linked List Content*/
System.out.println("Linked List Content: " +linkedlist);
linkedlist.addFirst(0);
linkedlist.addLast(6);
System.out.println("LinkedList Content after addition: " +linkedlist);
}
}