How To Create ArrayList In Java
In this program we make a arraylist and add element in it.Here
ArrayList<String> arr = new ArrayList<String>();
import java.util.ArrayList;
public class CreateArrayList {
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");
// print arraylist
System.out.println("arrayList is = " + arr);
}
}
public class CreateArrayList {
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");
// print arraylist
System.out.println("arrayList is = " + arr);
}
}
Output:
arrayList is = [c, php, html, java]
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