Im a beginner with java and i am following tutorials by Thenewboston on youtube. I wanted to go to a bit more advanced (in my opinion… but not really) things. So heres the code. I want to make it so that it repeats to the beginning so i can enter another number without restarting the program. I believe i have to use the return command but i am not sure where and how to. Thank you!
import java.util.Scanner;
class apples {
public static void main(String args[]) {
Scanner alex = new Scanner(System.in);
Double test;
test = alex.nextDouble();
if (test == 9) {
System.out.println("eat");
} else {
System.out.println("do not eat");
}
}
}
1 Answer