If I have a class as follows
class Log {
int rev;
String auth;
String date;
List<PathInfo> pathinfolist;
public LogProcess(int rev, String auth, String date,
List<PathInfo> pathinfolist) {
super();
this.rev = rev;
this.auth = auth;
this.date = date;
this.pathinfolist = pathinfolist;
}
public int getRev() {
return rev;
}
public void setRev(int rev) {
this.rev = rev;
}
public String getAuth() {
return auth;
}
public void setAuth(String auth) {
this.auth = auth;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public List<PathInfo> getPathinfolist() {
return pathinfolist;
}
public void setPathinfolist(List<PathInfo> pathinfolist) {
this.pathinfolist = pathinfolist;
}
}
I have a LinkedList<Log> called logobject. I have added almost a 1000 objects of Log to logobject using logobject.add().
Now how do I access/iterate these values of the data members from the linked list?
You can iterate over these by using an enhanced-for loop.
I would also encourage you to type your
LinkedListasList<Log> = new LinkedList<Log>(), so you don’t run into issues with retrieving elements from yourLinkedList.