How can I return value in a for loop ? For example if I have a loop that give me 3 numbers: 1,2,3... How can I return the value of the last number (here it is 3)?
public class Cod {
public static void main(String[] args) {
exp();
}
public static int exp() {
int x=10;
for (int i=1; i<=3;i++) {
x=x*10;
int y=x/10;
System.out.println(y);
return y;
}
}
}