What can be the return type of method getSwitch so that this program compiles and runs without any problems?
Code: Select all
public class TestClass{
public static XXX getSwitch(int x){
return x - 20/x + x*x;
}
public static void main(String args[]){
switch( getSwitch(10) ){
case 1 :
case 2 :
case 3 :
default : break;
}
}
}
How do we know that it returns an int? (Thanks in advance for your help!)