TsetsoP

T16; ARRAYLIST

Mar 5th, 2021
765
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2. public class AL{
  3.     public static void main(String[] args) {
  4.         ArrayList<Integer> ArrList = new ArrayList();
  5.         ArrList.add(32);
  6.         ArrList.add(2);
  7.         ArrList.add(12);
  8.         ArrList.add(41);
  9.         ArrList.add(18);
  10.         ArrList.add(54);
  11.         ArrList.add(19);
  12.         ArrList.add(67);
  13.  
  14.  
  15.         System.out.println("Content: " + ArrList);
  16.         System.out.println("Arr Size: " + ArrList.size());
  17.         System.out.println("To String: " + ArrList.toString());
  18.  
  19.         //REMOVE AT INDEX
  20.         System.out.println("Remove element at Index [4]: " + ArrList.remove(4));
  21.         System.out.println("Content now: " + ArrList);
  22.  
  23.         //ADD ELEMENT AT INDEX
  24.         System.out.println("Add element (7) at index[3]");
  25.         ArrList.add(3,7);
  26.         System.out.println("Content after add " + ArrList);
  27.         System.out.println("Arr size: " + ArrList.size());
  28.  
  29.         //REMOVE BY ELEMENT
  30.         System.out.println("Remove element (54) by value: " + ArrList.remove(Integer.valueOf(54)));
  31.         System.out.println("Content now: " + ArrList);
  32.  
  33.         //ADDING ELEMENT
  34.         System.out.println("Add element (22) at end: " + ArrList.add(22));
  35.         System.out.println("Content now: " + ArrList);
  36.  
  37.    }
  38. }
  39.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×