compareTo ()方法用于比较Number对象和方法的参数。 可用于Byte、Long、Integer等比较。
此方法用于比较两种相同的数据类型,两种不同类型的数据不能用此方法进行比较。
语法public int compare to (numbersubclassreferencename )参数http://www.Sina.com/--byte,Double,Integer,Float,Long或
如果为返回值指定的数量等于参数,则返回0。
如果指定的数量小于参数,则返回-1。
如果指定的数量大于参数,则返回1。
例: String date1='2017-03-08 ';
字符串数据2=' 2017-03-10 ';
字符串日期3=' 2017-03-02 ';
字符串日期4=' 2017-03-01 ';
system.out.println (date1.com Pareto ) date2 );
system.out.println (date3.com Pareto ) date4);
结果: -1 1