我正在尝试从数组列表中获取值。
我有如下用户类型的bean类..
class User{
public String link;
public String url;
User(String l,String u){
this.link=link;
this.url=url;
}
setters and getters below..
在这里,我正在尝试用 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 ..
}
我需要输出为:
link1 url1
link2 url2
link3 url2