Home>Article>Java> Java method to determine whether it is of type int

Java method to determine whether it is of type int

尚
Original
2019-12-14 10:20:39 7695browse

Java method to determine whether it is of type int

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 thejava basic tutorialcolumn.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn