I have a List that contains many rows of data.What i want to do is return only the first iterated value and nothing else.
public int getnumber() {
for (Bike temp : bikes) {
return temp.getBikeID();
break;
}
}
I tried something like the above..but the break statement is unreachable. How may i achieve this ?
I know that i could still just declare a variable outside of the loop then assign the value in the loop but the returned value will be the last row.
public int getnumber(){return bikes.get(0).getBikeId();}?bikes?