且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将用户输入保存在数组中?

更新时间:2021-10-22 21:57:55

好吧,如果您不能使用对象,那么您可以使用一种适用于一切的

Well if you cannot use Objects then you use one For Everything

   for (int i = 0; i < ID.length; i++) {
         System.out.print("\n       > Enter patient ID: ");
         ID[i] = input.nextInt();

        System.out.print("\n         > Enter patient First Name: ");
        first[i] = reader.nextLine();

        System.out.print("\n        > Enter patient last Name: ");
        last[i] = reader.nextLine();
                    }

现在,当有人通过ID搜索时,您只需要搜索保存位置的索引,该索引与名称和姓氏相同.希望对您有帮助

Now when someone search by ID you only need the search the index of where is it saved and is the same as the name and lastName. Hope if it help you