public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int size1 = v1.length, size2 = v2.length;
        int i = 0;
        for (; i < size1 && i < size2; ++i) {
            int val1 = Integer.parseInt(v1[i]), val2 = Integer.parseInt(v2[i]);
            if (val1 > val2)
                return 1;
            else if (val1 < val2) {
                return -1;
            }
        }
        if (i < size1 && Integer.parseInt(v1[i]) != 0)
            return 1;
        else if (i < size2 && Integer.parseInt(v2[i]) != 0)
            return -1;
        return 0;
    }