Jump to content
Sign in to follow this  
wesley

how show deleted item from arraylist

Recommended Posts

Hello,

 

I have java code. The code add and remove data from the arraylist.

 

My question is: how can I show the deleted item from the arraylist in system.out.println?

 

thanks in advance.

 

my code is:

public static void main(String[] args) {
        // TODO code application logic here
       ArrayList<String>items = new ArrayList<>();
       
       items.add("oval");
       items.add("polygon");
       items.add("spline");
       items.add("PaintedText");
       items.add("image");
       
       System.out.println("Size of list: " + items.size());
	
   // let us print all the elements available in list
   for (String number : items) {
   System.out.println(number);
   }  
	
   // Removes element at 3rd position
   items.remove(2);

   System.out.println( items.size());
	
   // let us print all the elements available in list
   for (String number : items) {
   System.out.println(number);
   }
   }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×