Java的。无法访问代码错误

时间:2018-02-22 09:41:51

标签: java

我的编程任务要求我们打印一个菜单系统,接受用户输入,然后继续重新打印菜单系统,直到敲击Break键。我收到了一个无法访问的代码错误,我之前从未见过我插入注释的内容。

import java.util.Scanner;
public class SkillsDemo02 {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
    System.out.println("______________________________");
    System.out.println("Welcome to the Voting Register");
    System.out.println("");
    System.out.println("Please Select one of the following:");
    System.out.println("1. Add a name to the Register");
    System.out.println("2. Search for a name on the register");
    System.out.println("3. Delete a name from te register");
    System.out.println("4. View all names on the register");
    System.out.println("");
    System.out.println("0. Exit");
    System.out.println("______________________________");
    int firstChoice = sc.nextInt();
    }
// int choice = sc.nextInt(); 
    if (choice == 1) {
        String names [] = new String [10];
        System.out.println("You have chosen option 1, to add a name to the register");
        System.out.println("Please enter your chosen name");
        String user = sc.nextLine();
        String user2 = sc.nextLine();
        System.out.println(user2);
        sc.close();
    }

}

}

0 个答案:

没有答案