The data type of the judgment value

If you get an Object object, you can use if (obj instanceof String) to determine whether it is a String object. Int is a basic type and cannot be judged like this. You can only use its wrapper class Integer, and also use instanceof


.If there are two Object parameters, you can use if(obj1.getClass()==obj2.getClass()) to judge whether the types are the same, if you want to get the type name, you can use obj.getClass().getName() to Get the class name of the object





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325852185&siteId=291194637
Recommended