//selectfruit 1 ,2,3? lets suppose
int selectfruit = 3;
if(selectfruit == 1) {
System.out.println("Apple");
} else if(selectfruit == 2){
System.out.println("Banana");
} else if(selectfruit == 3) {
System.out.println("Orange");
}
output will be Orange as you want.
solved Java Eclipse – Select, enter integer and display string [closed]