import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Scanner; /* * Write your code here. */ public class Teszt { /* * Write your code here. */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); List lista = new ArrayList<>(); while (sc.hasNextLine()) { String[] sorTomb = sc.nextLine().split(";"); if (sorTomb[0].equals("B")) { lista.add(new Bagoly(sorTomb[1], Integer.parseInt(sorTomb[2]), Double.parseDouble(sorTomb[3]))); } else if (sorTomb[0].equals("K")) { lista.add(new Kutya(sorTomb[1], Integer.parseInt(sorTomb[2]), Double.parseDouble(sorTomb[3]))); } } for (Allat a : lista) { System.out.println(a); } System.out.println(); Bagoly[] bt = legnehezebbUhuk(lista.toArray(new Allat[0])); Arrays.sort(bt, new Comparator() { @Override public int compare(Bagoly o1, Bagoly o2) { return Integer.compare(o1.getGyuruAzonosito(), o2.getGyuruAzonosito()); } }); for (Bagoly b : bt) { System.out.println(b); } } }