Here you can find the source of compareVersion(String appVer, String updateVer)
public static int compareVersion(String appVer, String updateVer)
//package com.java2s; public class Main { public static int compareVersion(String appVer, String updateVer) { if (appVer.equals(updateVer)) return 0; String[] appVerNum = appVer.split("\\."); String[] updateVerNum = updateVer.split("\\."); for (int i = 0; i < Math.min(appVerNum.length, updateVerNum.length); ++i) { if (Integer.parseInt(appVerNum[i]) > Integer .parseInt(updateVerNum[i])) return 1; else if (Integer.parseInt(appVerNum[i]) < Integer .parseInt(updateVerNum[i])) return -1; }// www. ja va 2 s . c om return appVerNum.length > updateVerNum.length ? 1 : -1; } }