Home > Java > javaTutorial > Comparison of two methods of converting Integer to int in Java

Comparison of two methods of converting Integer to int in Java

高洛峰
Release: 2017-02-11 15:48:20
Original
2473 people have browsed it

This article mainly introduces the comparison of two methods of converting Java Integer to int. It has a very good reference value. Let’s take a look at it with the editor.

Method 1:

Integer.parseInt(); Returns an int value.

Method 2:

new Integer.valueof();         返回的是 Integer 的对象。
new Integer.valueof().intValue();   返回的也是一个 int 的值。
Copy after login

Written test application examples:

Set the following two assignment statements:

a = Integer.parseInt(“123”);
b = Integer.valueOf(“123”).intValue();
Copy after login

The following statement is correct (d)

A. a is an integer type variable, and b is an integer type object.

B, a is an integer type object, and b is an integer type variable.

C, a and b are all integer class objects and their values ​​are equal.

D, a and b are all integer type variables and their values ​​are equal.

For more related articles comparing the two methods of converting Integer to int in Java, please pay attention to 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