-
return{Resolved}
public int woo(int a){
int y = 78;
for(int i=0; i<100; i+10){ //i+10 is invalid
if (i == a)
return y;
}
return a;
}
I want the method to return 'y' if 'a' == 'i'.
if i == a, will the for loop be stopped (no further loops) and y be returned (ending the method)?
therefore, if i != a, a will be returned?
by the way, how do i get the increment of i to be +10 in every pass?
-
Code:
public class X{
public static void main(String[] args){
for(int i = 0; i <=100; i += 10) {
System.out.println(i);
}
}
-
Code:
public class X{
public static void main(String[] args){
int result = woo(52);
System.out.println(result);
}
public static int woo(int a){
boolean match = false;
for(int i = 0; i <=100; i += 10){
if(i == a){
match = true;
break;
}
}
int result = match ? 78 : a;
return result;
}
}