Find odd number using function- error displayed "method must return int" | Selenium Forum
V
Vivek Posted on 08/06/2019


public class oddnum {


public static void main(String[] args) {
int O=odd(100);
System.out.println(O);
}

public static int odd(int num){

for(int i=2; i<=num; i++){
if(i%2==0){
return i;
}
}
}
}


A
Ashish Thakur Replied on 12/06/2019

You need to return an integer outside the for loop as well.