使用Java储存国家名称及人口

84 阅读1分钟
          final int MO = 6;
          String [] hours = new String[MO];
          Scanner keyboard = new Scanner(System.in);
          System.out.println("Please enter the country name and number of people in the country");
          for (int index = 0; index<MO; index++)
          {
              System.out.println("Country name and number of countries:" + (index + 1) + " : ");
              hours[index] = keyboard.nextLine();
          }
          System.out.println("The country name and number of countries you entered are:");
          for(int index = 0; index<MO; index++)
              System.out.println(hours[index]);
       }