Skip to content

Part1 by Iurii Salnikov#159

Open
u4s5 wants to merge 2 commits intojava8-course:masterfrom
u4s5:part1
Open

Part1 by Iurii Salnikov#159
u4s5 wants to merge 2 commits intojava8-course:masterfrom
u4s5:part1

Conversation

@u4s5
Copy link

@u4s5 u4s5 commented Jul 4, 2017

No description provided.

Arrays.sort(persons, new Comparator<Person>() {
@Override
public int compare(Person p1, Person p2) {
return p1.getAge() - p2.getAge();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect in general. Use Integer.compare.

};

// TODO use Arrays.sort
Arrays.sort(persons, Comparator.comparing(p -> p.getAge()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Comparator.comparingInt to avoid boxing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants