Home Tutorial Java Collections Arraylist Java arraylist int


Share on Google+Share on Google+
Java arraylist int
Posted on: October 23, 2009 at 12:00 AM
This section demonstrates the use of for loop for int data type.

  • arraylist can contain int data type elements also. 
  • Only wrapper class object is allowed to be added.
  • But due to boxing unboxing feature primitive datatype gets autoboxed into Wrapper class object.
  • In this example int data type gets converted into Integer data type.

Example of Java Arraylist int
import java.util.ArrayList;
import java.util.List;

public class List_for_int {
    public static void main(String[] args) {
        List list=new ArrayList();
       int arr1[]={11,12,13,14,15};
        for (int i = 0; i < arr1.length; i++) {
        for (int i = 0; i < arr1.length; i++) {
        System.out.println((i+1)+" : "+list.get(i));
1 : 11
2 : 12
3 : 13
4 : 14
5 : 15


Related Tags for Java arraylist int:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 23, 2009

Recommend the tutorial

Advertisements Advertisements