Java method example to determine whether it is an int type:
try { Integer iCheckValue = Integer.parseInt(sContentValue); if (iCheckValue instanceof Integer == false) { bCheckResult = false; } } catch(NumberFormatException e) { bCheckResult = false; }
instanceof is a binary operator in Java, similar to ==, >, <, etc. operator.
instanceof is a reserved keyword in Java. Its function is to test whether the object on its left is an instance of the class on its right and return the data type of boolean.
Usage:
result = object instanceof class
Parameters:
Result: Boolean type.
Object: required. Any object expression.
Class: required. Any defined object class.
Description:
If object is an instance of class, the instanceof operator returns true. Returns false if object is not an instance of the specified class, or if object is null.
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of Java method to determine whether it is of type int. For more information, please follow other related articles on the PHP Chinese website!