### Question:
CharArrayComparator implements Comparator<char[]> { private CharArrayComparator() { } private  CharArrayComparator(); int compare( char[] charArray1, char[] charArray2 ); static final CharArrayComparator INSTANCE; }### Answer:
@Test public void testCharArrayComparator() { CharArrayComparator comparator = CharArrayComparator.INSTANCE; assertEquals( 0, comparator.compare( null, null ) ); assertEquals( 0, comparator.compare( new char[] {}, new char[] {} ) ); assertEquals( 0, comparator.compare( new char[] { 'a', 'b' }, new char[] { 'a', 'b' } ) ); assertEquals( 1, comparator.compare( new char[] {}, null ) ); assertEquals( 1, comparator.compare( new char[] { 'a' }, null ) ); assertEquals( 1, comparator.compare( new char[] { 'a', 'b' }, new char[] { 'a', 'a' } ) ); assertEquals( 1, comparator.compare( new char[] { 'a', 'b', 'a' }, new char[] { 'a', 'b' } ) ); assertEquals( 1, comparator.compare( new char[] { 'a', 'b' }, new char[] { 'a', 'a', 'b' } ) ); assertEquals( -1, comparator.compare( null, new char[] {} ) ); assertEquals( -1, comparator.compare( null, new char[] { 'a', 'b' } ) ); assertEquals( -1, comparator.compare( null, new char[] { '\uffff', 'b' } ) ); assertEquals( -1, comparator.compare( new char[] {}, new char[] { 'a', 'b' } ) ); assertEquals( -1, comparator.compare( new char[] {}, new char[] { '\uffff', 'b' } ) ); assertEquals( -1, comparator.compare( new char[] { '0', 'a' }, new char[] { 'a', 'a', 'b' } ) ); char[] array = new char[3]; array[0] = 'a'; array[1] = 'b'; assertEquals( -1, comparator.compare( new char[] { 'a', 'b' }, array ) ); }