In java how to iterate over a list of objects

I have a list myEmpls

List myEmpls = new ArrayList();

In this list, I have added specific objects used.

LogConf e = getLogs(el);
    //add it to list
 myEmpls.add(e);

Now, how to iterate over the list of objects and get values ​​from these objects. How to do it?

+3
source share
1 answer

You could just go to Google and you will find many solutions. But here is the code:

for(LogConf element : myEmpls) {
  System.out.println(element.getValue());
}

You should also get used to determining the type of items in the list:

List<LogConf> myEmpls = new ArrayList<LogConf>();
+16
source

All Articles