Home > Java > JavaBase > body text

Java method to determine whether it is of type int

Release: 2019-12-14 10:20:39
Original
7710 people have browsed it

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;
}
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!