MCPcopy
hub / github.com/careercup/ctci / compare

Method compare

java/Chapter 18/Question18_7/LengthComparator.java:6–10  ·  view source on GitHub ↗
(String o1, String o2)

Source from the content-addressed store, hash-verified

4
5public class LengthComparator implements Comparator<String> {
6 public int compare(String o1, String o2) {
7 if (o1.length() < o2.length()) return 1;
8 if (o1.length() > o2.length()) return -1;
9 return 0;
10 }
11}

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected