forked from Nabin-joshi/java_notes_and_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arraylist.java
28 lines (25 loc) · 836 Bytes
/
arraylist.java
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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class arraylist {
public static void main(String[] args) {
ArrayList<Integer> arrayList =new ArrayList();
System.out.println("How much length you want");
Scanner sc =new Scanner(System.in);
int n;
n= sc.nextInt();
int element;
System.out.println("Enter "+n+" Elements");
for(int i=0;i<n;i++){
element= sc.nextInt();
arrayList.add(element);
}
System.out.println(arrayList);
arrayList.remove(n-1);
System.out.println(arrayList);
Collections.sort(arrayList,Collections.reverseOrder());
System.out.println(arrayList);
Collections.reverse(arrayList);
System.out.println(arrayList);
}
}