Object also has its own type, if Object types of data directly into strong Integer type conversion will appear abnormal
Object o = new Object();
Integer i = (Integer) o; //java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.Integer
Object type is converted to an Integer type Object first two methods :( by toString () or String.valueOf () to a String, and then by calling the method Integer String class type conversion tool type Integer, you should try abnormal type conversion)
-
Integer.parseInt(obj.toString());
-
Integer.parseInte(String.valueof(obj));