Answers for "comparetor java"

C
4

how to compareTo in java

x.compareTo(y) <  0     // x <  y
x.compareTo(y) <= 0     // x <= y
x.compareTo(y) != 0     // x != y
x.compareTo(y) == 0     // x == y
x.compareTo(y) >  0     // x >  y
x.compareTo(y) >= 0     // x >= y
Posted by: Guest on November-30-2021
0

java comparator comparing

1. Collections.sort(people,Comparator.comparing(Person::getLastName));

2.		Collections.sort(list,
		        Comparator.<Integer,Integer>comparing( i -> -grow[i])
		                  .thenComparing( i -> -plant[i]));

3.		Collections.sort(list,
		        Comparator.comparing( (Integer i) -> -grow[i])
		                  .thenComparing( i -> -plant[i]));

4.		Collections.sort(list,
		        Comparator.comparing( i -> -grow[(int)i])
		                  .thenComparing( i -> -plant[(int)i]));
Posted by: Guest on January-10-2022

Code answers related to "C"

Browse Popular Code Answers by Language