Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
swdev:java:lang:arraylist [2017/10/25 08:34]
smayr
swdev:java:lang:arraylist [2017/10/25 08:49] (current)
smayr [ArrayList]
Line 53: Line 53:
 </code> </code>
  
 +To process each object with the correct type: 
 +<code java> 
 +ArrayList<Object> listOfObjects = new ArrayList<Object>(); 
 +for(Object obj: listOfObjects) { 
 +   if (obj instanceof String) { 
 +       // handle String 
 +   } else if (obj instanceof Integer) { 
 +       // handle Integer 
 +   } else { 
 +       // handle others 
 +   } 
 +
 +</code>