SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class Main
  4. {
  5.     public static void main(String args[])
  6.     {
  7.       List<Integer> l=new ArrayList<>();
  8.       l.add(10);
  9.       l.add(20);
  10.       l.add(30);
  11.       l.add(10);
  12.       l.add(50);
  13.       l.add(60);
  14.       l.add(90);
  15.      
  16.       System.out.println(l);
  17.       List<Integer> l2 = new ArrayList<Integer>();
  18.         l2.add(11);
  19.         l2.add(22);
  20.         l2.add(33);
  21.        
  22.       l.addAll(0, l2);
  23.       System.out.println(l);
  24.      
  25.       l.remove(2);
  26.       System.out.println(l);
  27.      
  28.       l.set(0,99);
  29.       System.out.println(l);
  30.      
  31.       System.out.println(l.get(0));
  32.      
  33.       //show the First index of element else return -1
  34.       System.out.println(l.indexOf(10));
  35.      
  36.       //show the Last index of element else return -1
  37.       System.out.println(l.lastIndexOf(10));
  38.      
  39.       //Return List from index 2(including) to index 4(excluding)
  40.       System.out.println(l.subList(2, 4));
  41.      
  42.      
  43.        
  44.     }
  45.    
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top