Set<Student> ts = new TreeSet<Student>();
for(Student s : studentInfo){
ts.add(s);
}
System.out.println(ts);
I've written this above snippet in one of my case block in order to sort a collection of Student Objects.
My question is: What is the difference between using this approach and using Collections.sort();
method.