Sunday, 10 May 2015

how To Remove Element of arraylist

There we will remove one element of arraylist using remove().

import java.util.ArrayList;

public class RemoveElement {
    public static void main(String[] args) {
        ArrayList<String> arr = new ArrayList<String>();
        // add element in arraylist
        // print arraylist
        System.out.println("Before Remove Element ArrayList is = " + arr);
         * Removes the element at the specified position in this
           list. Shifts any subsequent elements to the left
        System.out.println("After Remove Element ArrayList is="+arr);


Before Remove Element ArrayList is = [c, php, html, java]

After Remove Element ArrayList is=[c, html, java]

Related Posts: 


Storing Java Object In ArrayList

No comments:

Post a Comment