Java Convert long to int – javatpoint

Java Convert long to int

Java Convert long to int

We can convert long to int in java using typecasting. To convert higher data type into lower, we need to perform typecasting.

Typecasting in java is performed through typecast operator (datatype).

Here, we are going to learn how to convert long primitive type into int and Long object into int.

Java long to int Example

Let’s see the simple code to convert long to int in java.

Output:

500

Java Long to int Example

We can convert Long object to int by intValue() method of Long class. Let’s see the simple code to convert Long to int in java.

Output:

10

Next Topic

Java int to double