Integer.valueOf--The Perfect Use Case Sorting With for Comparable #java #shorts #coding #airhacks

preview_player
Показать описание


#airhacks
Рекомендации по теме
Комментарии
Автор

You could also use Integer.compare(int, int) and pass Integer.parseInt(item.number) to avoid creating more Integers.

MrIStillDontCare
Автор

What happens if the valueOf method cannot parse the String into an Integer? Will it return null?

cihan
Автор

Or my preferred version:

items.stream()
->
.toList();

If you do not need to provide comparison to other modules.

MrIStillDontCare