Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Several methods of converting long type into int type in java
Several methods of converting long type into int type in java
Here are three ways to suit you:

First, basic types can be cast, because basic types of Java can be cast to each other.

long

l

=

new

Dragon (33);

long

l 1

=

l . long value();

Internationalorganizations (same as international organizations)

I

=

(integer)

l 1;

system . out . println(I);

Second, you can use toString () method to convert it Into a string, and then use Integer.parseInt to convert it into an int type.

long

l

=

new

Dragon (33);

line

s

=

l . tostring();

Internationalorganizations (same as international organizations)

I

=

integer . parse int(s);

system . out . println(I);

Third,

Long's api provides an intValue method, which can be converted into int.

long

l

=

new

Dragon (33);

system . out . println(l . int value());