小编use*_*790的帖子

在java中是否有一个命令使程序回到循环的开头

我试图在java中进行打字冒险类游戏,但是我需要一个至少类似于标题中的命令的命令,这里是代码

import java.util.Scanner;

public class MyFirstGameInJava {

public static void main(String[] args) {

System.out.println("Greetings, Enter your name and you may start your quest!");
Scanner Username = new Scanner(System.in);
String name = Username.nextLine();
System.out.println("Greetings " + name );
System.out.println("Welcome to an Unnamed Typing Advanture");
System.out.println("You find yourself on an island with very few trees, you can either hit a tree, or walk along");

String sc = Username.nextLine();

switch(sc){

case "Hit tree":
System.out.println("A coconut falls from the tree");
System.out.println("You can either eat …
Run Code Online (Sandbox Code Playgroud)

java command loops switch-statement

1
推荐指数
1
解决办法
5万
查看次数

标签 统计

command ×1

java ×1

loops ×1

switch-statement ×1