main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); List<Human> list = new ArrayList<>(); for(var i = 0; i < n; i++) { list.add(new Human(sc.nextDouble(), sc.nextDouble())); } } } class Human { public double height; public double weight; public Human(double height, double weight) { this.height = height; this.weight = weight; } } シンプルにデータを持つだけ Humanクラスをつくる
main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); List<Human> list = new ArrayList<>(); for(var i = 0; i < n; i++) { list.add(new Human(sc.nextDouble(), sc.nextDouble())); } list.sort(Comparator.naturalOrder()); } } class Human implements Comparable<Human> { public double height; public double weight; public Human(double height, double weight) { this.height = height; this.weight = weight; 完成!