I have an ArrayList item that holds Objects
ArrayList<Object> nodeList;
I fill it with records I retrieve form database like this
//start loop
nodeList.add(getResultSet().getString(i).trim());
//end loop
Now, I want to get those results, so I create a "getter" method
public Object getResults(){
for(int i = 0; i < nodeList.size(); i++){
return nodeList.get(i);
}
}
Netbeans tells me that return statement is missing, although I return every single object of the arrayList inside loop. How am I supposed to fix it? I tried to return an Array of Objects but it didn't work either. It's still in a loop an it wants to return something outside loop. Thank you in advance.
Strings in yourList, then change the type declaration toList<String>instead.List<Object>, instead create an entity with the desired fields and fill each field in a class instance.