Class StringLengthComparator

  • All Implemented Interfaces:
    Comparator

    public class StringLengthComparator
    extends Object
    implements Comparator
    This compares the length of two string.
    • Constructor Detail

      • StringLengthComparator

        public StringLengthComparator()
    • Method Detail

      • compare

        public int compare​(Object s1,
                           Object s2)
        Performs string comparison on string length.
        Specified by:
        compare in interface Comparator
        Parameters:
        s1 - first string.
        s2 - second string.
        Returns:
        0 if both strings have same length; less than 0 if length of s1 is longer than length of s2; greater than 0 if length of s1 is shorted than length of s2.