Size() Method return number of element in the arraylist.
import java.util.ArrayList;
public class CountElement {
public static void main(String[] args) {
ArrayList<String> arr = new ArrayList<String>();
// add element in arraylist
arr.add("c");
arr.add("php");
arr.add("html");
arr.add("java");
arr.add("delhi");
arr.add("INDIA");
// print arraylist
System.out.println("arrayList is = " + arr);
/*
* Returns the number of elements in this list.
*/
System.out.println(" size = "+arr.size());
}
}
Output:
arrayList is = [c, php, html, java, delhi, INDIA]
size = 6
Storing Java Object In ArrayList
How to count number of element in ArrayList
How to insert element in arraylist
How to use retailAll in arraylist
import java.util.ArrayList;
public class CountElement {
public static void main(String[] args) {
ArrayList<String> arr = new ArrayList<String>();
// add element in arraylist
arr.add("c");
arr.add("php");
arr.add("html");
arr.add("java");
arr.add("delhi");
arr.add("INDIA");
// print arraylist
System.out.println("arrayList is = " + arr);
/*
* Returns the number of elements in this list.
*/
System.out.println(" size = "+arr.size());
}
}
Output:
arrayList is = [c, php, html, java, delhi, INDIA]
size = 6
Related Posts:
How to count number of element in ArrayList
How to insert element in arraylist
How to use retailAll in arraylist
No comments:
Post a Comment