I've the below method which expects a return type as SomeObject. mapData() function returns SomeObject. I want to come out from the loop as soon as one condition gets satisfied. I'm getting compilation error due to no return type found. Can you please point out the issue with my condition ?
public static SomeObject mapper(List<String> mylist) {
Iterator iter = mylist.iterator();
while (iter.hasNext()) {
Object[] result = (Object[]) iter.next();
if (condition){
//dosomething
return mapData(abc);
}else if (condition) {
//dosomething
return mapData(def);
}else {
//dosomething
return mapData(ghi);
}
}
// Get compilation error due to no return type at this position
}