Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main
- {
- public static void main(String args[])
- {
- List<Integer> l=new ArrayList<>();
- l.add(10);
- l.add(20);
- l.add(30);
- l.add(10);
- l.add(50);
- l.add(60);
- l.add(90);
- System.out.println(l);
- List<Integer> l2 = new ArrayList<Integer>();
- l2.add(11);
- l2.add(22);
- l2.add(33);
- l.addAll(0, l2);
- System.out.println(l);
- l.remove(2);
- System.out.println(l);
- l.set(0,99);
- System.out.println(l);
- System.out.println(l.get(0));
- //show the First index of element else return -1
- System.out.println(l.indexOf(10));
- //show the Last index of element else return -1
- System.out.println(l.lastIndexOf(10));
- //Return List from index 2(including) to index 4(excluding)
- System.out.println(l.subList(2, 4));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement