Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java中,当它说;解析“时到达文件末尾?”;?_Java_File_If Statement - Fatal编程技术网

在Java中,当它说;解析“时到达文件末尾?”;?

在Java中,当它说;解析“时到达文件末尾?”;?,java,file,if-statement,Java,File,If Statement,因此,我即将在6小时内完成我的大项目,如果我添加了归档代码,我会发现一个错误,它说: E:\3 IB Computer Science SL\Dossier Computer Science IA The Solution\Product\Kingdom\u Hearts.java:664:解析时到达文件末尾 } 进程已完成 请注意,我的项目是一组相互之间的if语句,其中包含当用户输入3个数字(整数)时输出的文件。这到底意味着什么?我如何修复它?为了展示到目前为止我在整个课程中所掌握的知识: 编

因此,我即将在6小时内完成我的大项目,如果我添加了归档代码,我会发现一个错误,它说:

E:\3 IB Computer Science SL\Dossier Computer Science IA The Solution\Product\Kingdom\u Hearts.java:664:解析时到达文件末尾

}

进程已完成

请注意,我的项目是一组相互之间的if语句,其中包含当用户输入3个数字(整数)时输出的文件。这到底意味着什么?我如何修复它?为了展示到目前为止我在整个课程中所掌握的知识:

编辑:这是我在去掉2个不必要的大括号后得到的。我仍然得到相同的错误:

import java.io.*; //Allows for Files, and the IOException.
import java.util.*; //Allows for the scanner, which allows the user to make her or his choices.
public class Kingdom_Hearts 
{

public static void main (String[] args) throws IOException
{

    System.out.println("Select a Kingdom Hearts title to view enemies.");
    System.out.println("1. Kingdom Hearts");
    System.out.println("2. Kingdom Hearts: Final Mix");
    System.out.println("3. Kingdom Hearts: Chain of Memories");
    System.out.println("4. Kingdom Hearts II");
    System.out.println("5. Kingdom Hearts II: Final Mix");
    System.out.println("6. Kingdom Hearts: 358/2 Days");
    System.out.println("7. Kingdom Hearts: Birth by Sleep");
    System.out.println("8. Kingdom Hearts: Re:coded");
    System.out.println("9. Kingdom Hearts 3D: Dream Drop Distance");
                                                        //All the Kingdom Hearts games in the series to choose to view their enemies from.
    Scanner kH = new Scanner (System.in); //Allows the user to make any kind of selection throughout the enitire program.
    int choose = kH.nextInt();  //Gives the user the choice to select the number that corresponds to the Kingdom Hearts game.


    boolean looper = true;



    if (choose == 1) //enemies from the original Kingdom Hearts
    {
        System.out.println("In the orginal Kingdom Hearts, there is only one enemy race, which is the Heartless.");
        System.out.println("Please type the number which corresponds to the Heartless enemy type.");
        System.out.println("1. Pureblood"); //Gives the display for the user to know she can choose to view Pureblood Heartless.
        System.out.println("2. Emblem"); //Gives the display for the user to know she can choose to view Emblem Heartless.
        System.out.println("3. Special Heartless");
        int heartless_1 = kH.nextInt();
        if (heartless_1 == 1) //gives the chioce to select the Heartless enemy type
        {
            Scanner kH1 = new Scanner(new File("KH_Pureblood_Heartless.txt"));
            int maxIndex = -1; //So that when it's incremented below, the first index is 0.

            String[] kh1Purebloods = new String[10000]; //To be safe, more than what's needed is declared just in case.

            while (kH1.hasNext())
            {
                maxIndex++;
                kh1Purebloods[maxIndex] = kH1.nextLine();
            }

            kH1.close();

            for (int a = 0; a <= maxIndex; a++)
            {
                System.out.println(kh1Purebloods[a]);
            }
        }   

        if (heartless_1 == 2) //allows the user to select and view an Emblem Heartless enemy type
        {
            Scanner kH1_Emblem = new Scanner(new File("KH_Emblem_Heartless.txt"));
            int maxIndex = -1; //So that when it's incremented below, the first index is 0.

            String[] kh1Emblems = new String[10000]; //To be safe, more than what's needed is declared just in case.

            while (kH1_Emblem.hasNext())
            {
                maxIndex++;
                kh1Emblems[maxIndex] = kH1_Emblem.nextLine();
            }

            kH1_Emblem.close();

            for (int b = 0; b <= maxIndex; b++)
            {
                System.out.println(kh1Emblems[b]);
            }
        }

        if (heartless_1 == 3) //let's the user view information on Ansem the Wise, AKA Xehanort's Heartless
        {
            Scanner kH1_Special = new Scanner(new File("KH_Special_Heartless.txt"));
            int maxIndex = -1; //So that when it's incremented below, the first index is 0.

            String[] kh1Special = new String[10000]; //To be safe, more than what's needed is declared just in case.

            while (kH1_Special.hasNext())
            {
                maxIndex++;
                kh1Special[maxIndex] = kH1_Special.nextLine();
            }

            kH1_Special.close();

            for (int c = 0; c <= maxIndex; c++)
            {
                System.out.println(kh1Special[c]);
            }
        }

        else
        {
            System.out.println("Please enter a number which corresponds to one of the Heartless types in Kingdom Hearts.");
        }
     }

    if (choose == 2) //enemies from Kingdom Hearts: Final Mix
    {
        System.out.println("Please select the enemy race you wish to view:");
        System.out.println("1. Heartless");
        System.out.println("2. Nobodies");
        int kh_FM = kH.nextInt(); //gives the user the choice which enemy race to look at in Kingdom Hearts: Final Mix

            if (kh_FM == 1) //Allows the user to select which kinds of Heartless to view from Kingdom Hearts: Final Mix
            {
                System.out.println("Please type the number which corresponds to the Heartless enemy type.");
                System.out.println("1. Pureblood");
                System.out.println("2. Emblum");
                System.out.println("3. Special Heartless");
                int heartless_2 = kH.nextInt(); //gives the chioce to select the Pureblood Heartless she wishes to view.

                if (heartless_2 == 1) //allows the user to select and view a Pureblood Heartless enemy type
                {
                    Scanner kH1FM = new Scanner(new File("KHFM_Pureblood_Heartless.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] kh1FM = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kH1FM.hasNext())
                    {
                        maxIndex++;
                        kh1FM[maxIndex] = kH1FM.nextLine();
                    }

                    kH1FM.close();

                    for (int d = 0; d <= maxIndex; d++)
                    {
                        System.out.println(kh1FM[d]);
                    }
                }

                if (heartless_2 == 2) //allows the user to select and view an Emblum Heartless enemy type
                {
                    Scanner kH1FM_Emblem = new Scanner(new File("KHFM_Emblem_Heartless.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] kh1FMEmblems = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kH1FM_Emblem.hasNext())
                    {
                        maxIndex++;
                        kh1FMEmblems[maxIndex] = kH1FM_Emblem.nextLine();
                    }

                    kH1FM_Emblem.close();

                    for (int e = 0; e <= maxIndex; e++)
                    {
                        System.out.println(kh1FMEmblems[e]);
                    }
                }

                if (heartless_2 == 3) //let's the user view information on Ansem the Wise, AKA Xehanort's Heartless
                {
                    Scanner kH1FM_Special = new Scanner(new File("KHFM_Special_Heartless.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] kh1FMSpecial = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kH1FM_Special.hasNext())
                    {
                        maxIndex++;
                        kh1FMSpecial[maxIndex] = kH1FM_Special.nextLine();
                    }

                    kH1FM_Special.close();

                    for (int f = 0; f <= maxIndex; f++)
                    {
                        System.out.println(kh1FMSpecial[f]);
                    }
                }   
                else
                    {
                        System.out.println("Please enter a number which corresponds to one of the Heartless types in Kingdom Hearts: Final Mix.");
                    }
                }
             if (kh_FM == 2) //allows the user to view the one and only Nobody in Kingdom Hearts: Final Mix
             {
                Scanner kH1FM_Nobody = new Scanner(new File("KHFM_Special_Nobody.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh1FMSpecial_Nobody = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH1FM_Nobody.hasNext())
                {
                    maxIndex++;
                    kh1FMSpecial_Nobody[maxIndex] = kH1FM_Nobody.nextLine();
                }

                kH1FM_Nobody.close();

                for (int g = 0; g <= maxIndex; g++)
                {
                    System.out.println(kh1FMSpecial_Nobody[g]);
                }
             }
                else
                {
                    System.out.println("Please enter a number which corresponds to one of the enemy types in Kingdom Hearts: Final Mix.");
                }
            }




    if (choose == 3) //enemies from Kingdom Hearts: Chain of Memories
    {
        System.out.println("Please select the enemy race you wish to view:");
        System.out.println("1. Heartless");
        System.out.println("2. Nobodies");
        int enemies_3 = kH.nextInt();

        if (enemies_3 == 1) //allows the user to choose which type of Heartless to view in KH: Chain of Memories
        {
            System.out.println("Please type the number which corresponds to the Heartless enemy type.");
            System.out.println("1. Pureblood");
            System.out.println("2. Emblem");
            int heartless_3 = kH.nextInt();

            if (heartless_3 == 1) //allows the user to select and view a Pureblood Heartless enemy type
            {
                    Scanner kHCOM = new Scanner(new File("KHCOM_Pureblood_Heartless.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] khCOM = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kHCOM.hasNext())
                    {
                        maxIndex++;
                        khCOM[maxIndex] = kHCOM.nextLine();
                    }

                    kHCOM.close();

                    for (int h = 0; h <= maxIndex; h++)
                    {
                        System.out.println(khCOM[h]);
                    }
            }

            if (heartless_3 == 2) //allows the user to select and view a Emblem Heartless enemy type
            {
                    Scanner kHCOM_Emblem = new Scanner(new File("KHCOM_Emblem_Heartless.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] khCOMEmblems = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kHCOM_Emblem.hasNext())
                    {
                        maxIndex++;
                        khCOMEmblems[maxIndex] = kHCOM_Emblem.nextLine();
                    }

                    kHCOM_Emblem.close();

                    for (int i = 0; i <= maxIndex; i++)
                    {
                        System.out.println(khCOMEmblems[i]);
                    }
            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the Heartless types in KH: Chain of Memories.");
            }
        }



            if (enemies_3 == 2) //allows the user to see the Nobodies in KH: COM.
            {
                    Scanner kHCOM_Nobody = new Scanner(new File("KHCOM_Organization_XIII.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] khCOM_Organization = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kHCOM_Nobody.hasNext())
                    {
                        maxIndex++;
                        khCOM_Organization[maxIndex] = kHCOM_Nobody.nextLine();
                    }

                    kHCOM_Nobody.close();

                    for (int j = 0; j <= maxIndex; j++)
                    {
                        System.out.println(khCOM_Organization[j]);
                    }
            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the enemy races KH: Chain of Memories.");
            }

    }



    if (choose == 4) //enemies from the original Kingdom Hearts II
    {
        System.out.println("Please select the enemy race you wish to view:");
        System.out.println("1. Heartless");
        System.out.println("2. Nobodies");
        int enemies_4 = kH.nextInt();

        if (enemies_4 == 1) //Allows the user to select which kinds of Heartless to view from Kingdom Hearts II.
        {
            System.out.println("Please type the number which corresponds to the Heartless enemy type.");
            System.out.println("1. Pureblood");
            System.out.println("2. Emblem");
            System.out.println("3. Gummi");
            int heartless_4 = kH.nextInt();

            if (heartless_4 == 1) //allows the user to view Pureblood Heartless from KH2
            {
                Scanner kH2 = new Scanner(new File("KH2_Purebloods.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2Purebloods = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2.hasNext())
                {
                    maxIndex++;
                    kh2Purebloods[maxIndex] = kH2.nextLine();
                }

                kH2.close();

                for (int k = 0; k <= maxIndex; k++)
                {
                    System.out.println(kh2Purebloods[k]);
                }
            }

            if (heartless_4 == 2) //allows the user to view the Emblem Heartless in KH2
            {
                        Scanner kH2_Emblem = new Scanner(new File("KH2_Emblems.txt"));
                        int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                        String[] kh2Emblems = new String[10000]; //To be safe, more than what's needed is declared just in case.

                        while (kH2_Emblem.hasNext())
                        {
                            maxIndex++;
                            kh2Emblems[maxIndex] = kH2_Emblem.nextLine();
                        }

                        kH2_Emblem.close();

                        for (int l = 0; l <= maxIndex; l++)
                        {
                            System.out.println(kh2Emblems[l]);
                        }   
            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the Heartless types KH2.");
            }
        }


        if (enemies_4 == 2) //allows the user to view all of the Nobodies in KH2
        {
            System.out.println("Please type the number which corresponds to the Nobody enemy type.");
            System.out.println("1. Lower");
            System.out.println("2. Gummi");
            int nobodies_4 = kH.nextInt();

            if (nobodies_4 == 1) //Gives the selection of the Lower Nodies in Kingdom Hearts II.
            {
                    Scanner kH2_Lower = new Scanner(new File("KH2_Lower_Nobodies.txt"));
                    int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                    String[] kh2Lower = new String[10000]; //To be safe, more than what's needed is declared just in case.

                    while (kH2_Lower.hasNext())
                    {
                        maxIndex++;
                        kh2Lower[maxIndex] = kH2_Lower.nextLine();
                    }

                    kH2_Lower.close();

                    for (int m = 0; m <= maxIndex; m++)
                    {
                        System.out.println(kh2Lower[m]);
                    }
            }

            if (nobodies_4 == 2) //Gives the selection of the Gummi Nobodies, which are ONLY in Kingdom Hearts II
                                //(as well as the Final Mix version of it).
            {
                Scanner kH2_Gummi = new Scanner(new File("KH2_Gummi_Nobodies.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2Gummi = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2_Gummi.hasNext())
                {
                    maxIndex++;
                    kh2Gummi[maxIndex] = kH2_Gummi.nextLine();
                }

                kH2_Gummi.close();

                for (int n = 0; n <= maxIndex; n++)
                {
                    System.out.println(kh2Gummi[n]);
                }

            if (nobodies_4 == 3) //Give the selection of all he members of Organization XIII which appear in
                                    //Kingdom Hearts II.
            {
                Scanner kH2_Org = new Scanner(new File("KH2_Organization_XIII.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2Org = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2_Org.hasNext())
                {
                    maxIndex++;
                    kh2Org[maxIndex] = kH2_Org.nextLine();
                }

                kH2_Org.close();

                for (int o = 0; o <= maxIndex; o++)
                {
                    System.out.println(kh2Org[o]);
                }
            }       
            else
            {
                System.out.println("Please enter a number which corresponds to one of the Nobody types KH2.");
            }
        }
        else
        {
            System.out.println("Please input a number which corresponds to an enemy.");
        }
    }



      if (choose == 5)//enemies from Kingdom Hearts II: Final Mix
      {
        System.out.println("Please select the enemy race you wish to view:");
        System.out.println("1. Heartless");
        System.out.println("2. Nobodies");
        int enemies_5 = kH.nextInt();

        if (enemies_5 == 1) //Allows the user to select which kinds of Heartless to view from Kingdom Hearts II.
        {
            System.out.println("Please type the number which corresponds to the Heartless enemy type.");
            System.out.println("1. Pureblood");
            System.out.println("2. Emblem");
            System.out.println("3. Gummi");
            int heartless_5 = kH.nextInt();

            if (heartless_5 == 1) //allows the user to view Pureblood Heartless from KH2FM
            {
                Scanner kH2FM = new Scanner(new File("KH2FM_Purebloods.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2FMPurebloods = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2FM.hasNext())
                {
                    maxIndex++;
                    kh2FMPurebloods[maxIndex] = kH2FM.nextLine();
                }

                kH2FM.close();

                for (int p = 0; p <= maxIndex; p++)
                {
                    System.out.println(kh2FMPurebloods[p]);
                }
            }

            if (heartless_5 == 2) //allows the user to view the Emblem Heartless in KH2FM
            {
                Scanner kH2FM_Emblem = new Scanner(new File("KH2FM_Emblems.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2FMEmblems = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2FM_Emblem.hasNext())
                {
                    maxIndex++;
                    kh2FMEmblems[maxIndex] = kH2FM_Emblem.nextLine();
                }

                    kH2FM_Emblem.close();

                    for (int l = 0; l <= maxIndex; l++)
                    {
                        System.out.println(kh2FMEmblems[l]);
                    }   
            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the Heartless types in KH2FM.");
            }
        } 

        if (enemies_5 == 2) //allows the user to view all of the Nobodies in KH2
        {
            System.out.println("Please type the number which corresponds to the Nobody enemy type.");
            System.out.println("1. Lower");
            System.out.println("2. Gummi");
            int nobodies_5 = kH.nextInt();

            if (nobodies_5 == 1) //Gives the selection of the Lower Nodies in Kingdom Hearts II.
            {
                Scanner kH2_Lower = new Scanner(new File("KH2_Lower_Nobodies.txt"));
                int maxIndex = -1; //So that when it's incremented below, the first index is 0.

                String[] kh2Lower = new String[10000]; //To be safe, more than what's needed is declared just in case.

                while (kH2_Lower.hasNext())
                {
                    maxIndex++;
                    kh2Lower[maxIndex] = kH2_Lower.nextLine();
                }

                kH2_Lower.close();

                for (int m = 0; m <= maxIndex; m++)
                {
                    System.out.println(kh2Lower[m]);
                }
            }

            if (nobodies_5 == 2) //Gives the selection of the Gummi Nobodies, which are ONLY in Kingdom Hearts II
                                    //(as well as the Final Mix version of it).
            {

            }

            if (nobodies_5 == 3) //Give the selection of all he members of Organization XIII which appear in
                                //Kingdom Hearts II: Final Mix.
            {

            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the Nobody types KH2FM.");
            }
        }

        else
        {
            System.out.println("Please enter a number which corresponds to one of the enemy races KH2FM.");
        }

      }

       if (choose == 6) //enemies from Kingdom Hearts: 358/2 Days
       {
            System.out.println("Please select the enemy race you wish to view:");
            System.out.println("1. Heartless");
            System.out.println("2. Nobodies");
            int enemies_6 = kH.nextInt();

            if (enemies_6 == 1) //Allows the user to choose the type of Heartless to view in KH: 358/2 Days.
            {
                System.out.println("Please type the number which corresponds to the Heartless enemy type.");
                System.out.println("1. Pureblood");
                System.out.println("2. Emblem");
                int heartless_6 = kH.nextInt();

                if (heartless_6 == 1) //Allows the user to select which types of Pureblood Heartless to view.
                {

                }

                if (heartless_6 == 2) //Allows the user to select which Elblem Heartless in KH: 358/2 Days to view.
                {               

                }

                else
                {
                    System.out.println("Please enter a number which corresponds to one of the Heartless types KH: 358/2 Days.");
                }
            }

            if (enemies_6 == 2) //Gives the user the option to view the Nobodies featured in KH: 358/2 Days
            {
                System.out.println("Please type the number which corresponds to the Nobody enemy type.");
                System.out.println("1. Lower");
                System.out.println("2. Special");
                System.out.println("3. Organization XIII");
                int nobodies_6 = kH.nextInt();

                if (nobodies_6 == 1) //Allows the user to view the Lower Nobodies in KH: 358/2 Days.
                {

                }

                if (nobodies_6 == 2) //Allows the user to view information on the only Special Nobody in KH: 358/2 Days.
                {

                }

                if (nobodies_6 == 3) //Allows the user to view all of the members in Organization XIII in KH: 358/2 Days.
                {

                }

                else
                {
                    System.out.println("Please enter a number which corresponds to one of the Nobody types KH 358/2 Days.");
                }
            }

            else
            {
                System.out.println("Please enter a number which corresponds to one of the enemy races KH 358/2 Days.");
            }
        }


        if (choose == 7) //enemies from both the orginial Kingdom Hearts: Birth by Sleep, and
                    //Kingdom Hearts: Birth by Sleep: Final Mix
            {
                System.out.println("Please select the enemy race you wish to view:");
                System.out.println("1. Heartless");
                System.out.println("2. Unversed");
                int enemies_7 = kH.nextInt();

                if (enemies_7 == 1) //Allows the user to view all the (Pureblood) Heartless in KH: Birth by Sleep (Final Mix)
                                    //Note: Besides the Neoshadows, every other Heartless are only in the Final Mix version.
                    {

                    }

                if (enemies_7 == 2) //Allows the user to all of the Unversed in Kingdom Hearts: Birth by Sleep.
                    {

                    }

                else
                {
                    System.out.println("Please enter a number which corresponds to one of the enemy races KH: BBS.");
                }
            }

        if (choose == 8) //enemies from Kingdom Hearts: Re:coded
            {
                System.out.println("Please select the enemy race you wish to view:");
                System.out.println("1. Heartless");
                System.out.println("2. Nobodies");
                int enemies_8 = kH.nextInt();

                if (enemies_8 == 1)
                {

                }
                    System.out.println("Please type the number which corresponds to the Heartless enemy type.");
                    System.out.println("1. Pureblood");
                    System.out.println("2. Emblem");
                    int heartless_8 = kH.nextInt();

                    if (heartless_8 == 1) //Allows the user to choose which Pureblood Heartless to view in KH: Re:coded.
                    {

                    }

                    if (heartless_8 == 2) //Allows the user to choose which Emblem Heartless to view in KH: Re:coded.
                    {

                    }

                    else
                    {
                        System.out.println("Please enter a number which corresponds to one of the Heartless types KH: Re:coded.");
                    }

                if (enemies_8 == 2) //Allows the user to choose which kind of Nobodies to view.
                {
                    System.out.print("Please type in the number that corresponds to the only Nobody type in ");
                    System.out.println("Kingdom Hearts: Re:coded.");
                    System.out.println("1. Organization XIII");
                    int nobodies_8 = kH.nextInt();

                    if (nobodies_8 == 1) //Give the user the option to view the only Nobody in Kingdom Hearts: Re:coded.
                    {

                    }

                    else
                    {
                            System.out.println("Please enter a number which corresponds to the Nobody type KH: Re:coded.");
                    }
                }

                else
                {
                    System.out.println("Please enter a number which corresponds to one of the enemy races KH: Re:coded.");
                }
            }


        if (choose == 9) //enemies from Kingdom Hearts 3D: Dream Drop Distance
            {
                System.out.print("Please select the number that correspnds to the only fightable enemy");
                System.out.println(" in Kingdom Hearts 3D: Dream Drop Distance.");
                System.out.println("1. Dream Eaters");
                int enemies_9 = kH.nextInt();

                if (enemies_9 == 1) //Allows the user to select the Dream Eater she wishes to have information about.
                {

                }

                else
                {
                    System.out.println("Please enter a number which corresponds to one of the Dream Eaters in KH 3D: Dream Drop Distance.");
                }
            }

        else
        {
            System.out.println("Please enter a number which corresponds to one of the Kingdom Hearts games.");
        }
}
import java.io.*//允许文件和IOException。
导入java.util.*//允许扫描仪,允许用户进行选择。
公营阶层
{
公共静态void main(字符串[]args)引发IOException
{
System.out.println(“选择一个王国名称来查看敌人”);
System.out.println(“1.Kingdom Hearts”);
System.out.println(“2.王国之心:最终混音”);
System.out.println(“3.王国之心:记忆之链”);
System.out.println(“4.Kingdom Hearts II”);
System.out.println(“5.Kingdom Hearts II:最终混音”);
System.out.println(“6.王国心脏:358/2天”);
System.out.println(“7.王国之心:睡眠诞生”);
System.out.println(“8.王国之心:重新编码”);
System.out.println(“9.Kingdom Hearts 3D:梦滴距离”);
//所有的王国之心系列游戏都可以选择从中查看他们的敌人。
Scanner kH=new Scanner(System.in);//允许用户在整个程序中进行任何类型的选择。
int choose=kH.nextInt();//允许用户选择与游戏对应的数字。
布尔循环=真;
if(choose==1)//来自原始王国之心的敌人
{
在原始王国的心中,只有一个敌人种族是无情的;
System.out.println(“请键入与无情敌人类型对应的数字。”);
System.out.println(“1.Pureblood”);//为用户提供显示,让用户知道她可以选择查看Pureblood Heartless。
System.out.println(“2.徽章”);//显示给用户,让用户知道她可以选择无情地查看徽章。
System.out.println(“3.特别无情”);
int heartless_1=kH.nextInt();
if(heartless_1==1)//让chioce选择无情的敌人类型
{
扫描仪kH1=新扫描仪(新文件(“KH_Pureblood_Heartless.txt”);
int maxIndex=-1;//因此当它在下面递增时,第一个索引是0。
String[]kh1Purebloods=new String[10000];//为了安全起见,声明了超出需要的内容,以防万一。
while(kH1.hasNext())
{
maxIndex++;
kh1Purebloods[maxIndex]=kH1.nextLine();
}
kH1.close();

对于(inta=0;a,当代码中缺少“}”时,通常会出现语法错误,从而得到文件的结尾

在下一行后面有一个“{”,我认为这是不必要的

 int heartless_2 = kH.nextInt(); //gives the chioce to select the Pureblood Heartless she wishes to view.
            {

解析时,而不是“语法分析”时。请准确。这是编译器告诉您最好不要用单个方法编写所有内容的方式。}到底去了哪里?我刚刚删除了它,但仍然会遇到相同的错误。现在该怎么办?有一个不必要的大括号{'在上面提到的a行之后。尝试将其删除。在
int frus_3=kH.nextInt()行之后有另一个大括号。{
您是否有意将其标记为代码块?如果不是,这些可能会导致问题。我将这两个大括号都去掉,但仍然会出现错误。