How to remove the third element from an ArrayList in Java

1 Answer

0 votes
import java.util.ArrayList;
import java.util.Arrays;

public class MyClass {
    public static void main(String args[]) {
        ArrayList<Integer> al = new ArrayList<>(Arrays.asList(12, 90, 87, 40, 50, 99)); 
  
        System.out.println(al); 
           
        al.remove(2); 

        System.out.println(al); 
   
    }
}
     
     
     
     
     
/*
run:
     
[12, 90, 87, 40, 50, 99]
[12, 90, 40, 50, 99]
 
*/

 



answered Aug 22, 2021 by avibootz

Related questions

1 answer 112 views
4 answers 466 views
1 answer 188 views
1 answer 259 views
1 answer 177 views
2 answers 216 views
...