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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...