0

hi all
i have a java collection question.

i m using java list collection in my program and i m very confused how to iterate over the list

what i have i like
List<object> obj = ArrayList<object>();

now how can i iterate over this if somebody can explain me that will be great. thanks

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ezzaral
0

hi all
i have a java collection question.

i m using java list collection in my program and i m very confused how to iterate over the list

what i have i like
List<object> obj = ArrayList<object>();

now how can i iterate over this if somebody can explain me that will be great. thanks

Heres the sample code:

ArrayList<String> arr=new ArrayList<String>();
		arr.add("Test");
		arr.add("Test1");
		arr.add("Test2");
		arr.add("Test3");
		arr.add("Test4");
		
		for(String a : arr){
			System.out.println("Value : "+a);
		}

Output:

Value : Test
Value : Test1
Value : Test2
Value : Test3
Value : Test4

Regards,

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.