Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

compare function in java


        Collections.sort(marvelHeroes, new Comparator<String>() {
            @Override
            public int compare(String hero1, String hero2) {
                return hero1.compareTo(hero2);
            }
        });

        Collections.sort(marvelHeroes, (m1, m2) -> m1.compareTo(m2));

        Collections.sort(marvelHeroes, Comparator.naturalOrder());
Source by www.infoworld.com #
 
PREVIOUS NEXT
Tagged: #compare #function #java
ADD COMMENT
Topic
Name
6+2 =