### Question:
VersionComparator implements Comparator<String> { public static int compareVersion(final String version1, final String version2) { return INSTANCE.compare(version1, version2); } private  VersionComparator(); static int compareVersion(final String version1, final String version2); @Override int compare(final String o1, final String o2); static VersionComparator INSTANCE; }### Answer:
@Test public void testComparator() { final String version = "3.1"; Assert.assertTrue(VersionComparator.compareVersion("3.1.1", version) > 0); Assert.assertTrue(VersionComparator.compareVersion("3.1", version) == 0); Assert.assertTrue(VersionComparator.compareVersion("3.0", version) < 0); Assert.assertTrue(VersionComparator.compareVersion("3.0.1", version) < 0); Assert.assertTrue(VersionComparator.compareVersion("3.0.1", version) < 0); Assert.assertTrue(VersionComparator.compareVersion("3.1.x", version) == 0); }