I am trying to get the values from an arraylist.
I have the User type bean class as below..
class User{
public String link;
public String url;
User(String l,String u){
this.link=link;
this.url=url;
}
setters and getters below..
Here I am trying to write a class with main.
public class ListClass{
public static void main(String args[]){
List<User> list = new ArrayList<User>();
list.add(new User("link1","url1"));
list.add(new User("link2","url2"));
list.add(new User("link3","url3"));
//here i want to iterate both links and urls one by one
Iterator it=list.iterator();
// remaining the code to get both link1 and url1 ..
}
I need the output as:
link1 url1
link2 url2
link3 url2
You can use the for-in construct instead of the Iterator:
If you definitely want to use the iterator: