-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedlist.java
More file actions
32 lines (31 loc) · 910 Bytes
/
Linkedlist.java
File metadata and controls
32 lines (31 loc) · 910 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
import java.util.*;
public class Linkedlist{
public static void main(String[] args){
LinkedList<Integer> L1= new LinkedList<Integer>();
LinkedList<Integer> L2= new LinkedList<Integer>();
L1.add(1);
L1.add(3);
L1.add(5);
L1.add(7);
L1.add(9);
L2.add(2);
L2.add(4);
L2.add(6);
L2.add(8);
L2.add(10);
L1.addAll(L2);
System.out.println(L1 + " ");
int Long=L1.size();
for(int count1=0;count1<Long;count1++){
for(int count2=0;count2<Long-1;count2++){
if(L1.get(count2)>L1.get(count2+1)){
int temp=L1.get(count2);
L1.set(count2,L1.get(count2+1));
L1.set(count2+1,temp);
}
}
}
System.out.println(L1 + " ");
System.out.println(L2 + " ");
}
}