Powered by Blogger.

How to Iterate Generic type of ArrayList

>> Sunday, June 10, 2012

Generics in Java
Generics were introduced in Java 1.5 to define abstract types for the variables of by enclosing a comma-separated list of their names within angle brackets after the name of the class or interface. We can user this type of variables any where in the class if a type is required in any instance fields or methods of the class.

Now in this post we are learning how to iterate the Generic type of list.

Normally we used to iterate any list we take the help of Iterator. If it is normal list as well we can iterate the Generic type.

Lets take a bean class of User with a constructor and setters and getters methods.

Here the User having the String type name and link variables.

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.