I get the error from Java Version 8: "uses unchecked or unsafe operations".
It seems like the problem is comming from Collections.sort()
, but what is the problem? I've checked the Java Doc and everything seems to be fine, except that the argument is a List
, but ArrayList
is a List
as far as I'm concerned?
import java.util.ArrayList;
import java.util.Collections;
public class Driver
{
public static void test()
{
ArrayList<Person> persons = new ArrayList<Person>();
persons.add(new Person("Hans", "Car License"));
persons.add(new Person("Adam", "Motorcycle License"));
persons.add(new Person("Tom", "Car License"));
persons.add(new Person("Kasper", "Car License"));
System.out.println(persons);
Collections.sort(persons);
System.out.println(persons);
System.out.println(Collections.max(persons));
System.out.println(Collections.min(persons));
}
}