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

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,

Which is exactly what is in the link that Masijade already posted above. :-/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.