当前位置: 首页 > 知识库问答 >
问题:

我在开关的情况2中遇到了一个问题,给了我NoSuchelementException?

南门意蕴
2023-03-14

我有下面的代码,在学校的Windows计算机中可以正常工作,但在我的macOS中就不工作了。案例2应该给出一个学生的班级号,但它只给出了我的macOS中的NoSuchelementException。为什么它在我的macOS中不起作用?

case 2:
            System.out.println("Inserisci il cognome dello studente");
            String surname = scan.next();
            System.out.println("");
            System.out.println("Inserisci il nome dello studente");
            String name = scan.next();
            System.out.println("");

            File directory = new File("files" + File.separator + "class");;
            int fileCount = directory.list().length;
            for(int i=0; i< fileCount; i++ ){
                cn = ClassNumber.values()[enumNumb];
                if(enumNumb<3){
                    for(int j = 1; j<6; j++){
                        File serchStudents = new File("files" + File.separator + "class//" + j + cn + ".txt");
                        Scanner scS = new Scanner(serchStudents);
                        while(scS.hasNextLine()){
                            if(surname.equals(scS.next())/*&& name.equals(sc.next())*/){
                                System.out.print(j);
                                System.out.println(cn);
                                enumNumb=0;
                            }
                        }
                    }
                    enumNumb++;
                }
                if(enumNumb>=3){
                    for(int j = 3; j<6; j++){
                        File serchStudents = new File("files" + File.separator + "class" + File.separator + j + cn + ".txt");
                        Scanner scS = new Scanner(serchStudents);
                        while(scS.hasNextLine()){
                            if(surname.equals(scS.next())/*&& name.equals(sc.next())*/){
                                System.out.println("Lo studente fa parte della classe : ");
                                System.out.print(j);
                                System.out.println(cn);
                                i=fileCount;
                                enumNumb=0;
                            }
                        }
                    }
                    enumNumb++;
                }
            }
            System.out.println("Vuoi fare altro ?");
            answer = scan.next();
            break;

共有1个答案

吕博耘
2023-03-14

我刚刚在netBeans上安装了一些需要安装的东西,它已经工作了,所以我想它很好。

 类似资料:
  • 在react native中遇到问题“无法安装应用程序。请确保您拥有Android开发环境”

  • 在运行这个命令时,我能够安装其他的pip库而不是pycopg2--pip install psycopg2。我使用的是Azure Linux VM-Ubuntu18.04LTS,并在settings.py中设置了数据库配置。以下是一个问题: 错误:无效命令“BDIST_WHEAL” psycopg2生成轮失败,运行setup.py clean for psycopg2生成psycopg2失败,安装

  • 失败:生成失败,出现异常。 问题:配置根项目“android”时出现问题 无法解析配置“classpath”的所有项目。找不到组织。喷气式飞机。kotlin:kotlin gradl电子插件:1.3.50。在以下位置搜索:-https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50

  • 编辑:我刚刚意识到,即使是一个带有应用程序条的简单屏幕,也会发生这种情况 错误:任务“:app:checkdebugaarmadata”的执行失败 无法解析配置“:app:debugRuntimeClasspath”的所有文件。无法解析com。谷歌。firebase:firebase firestore:22.1.2。所需人员:项目:应用程序 无法解析com。谷歌。firebase:firebas

  • 我的合并排序算法无法正常工作。代码在下面,但是我简单总结一下我试过的,我知道的代码没有错的地方。 函数将指向数组的指针和数组的大小作为参数。如果数组的大小小于2,它会立即返回。我确信这是有效的,因为我调试了这部分几次。它返回了8次,这是我期望它做的。接下来,创建一个变量作为索引来拆分数组。我测试了它,我很有信心在所有递归中都是正确的。然后,创建两个数组,第一个数组包含索引…中的元素,第二个数组包含

  • 我在提取.7z受保护的文件时收到此错误 org . tuka ani . xz . corruptedinputexception:压缩数据损坏 我正在使用这个代码 如果你知道有什么问题,请告诉我。提前谢谢