Long to primitive long java

Convert long primitive to Long object in Java

To convert long primitive to Long object, follow the below steps.

Let’s say the following is our long primitive.

// primitive long val = 45; System.out.println("long primitive: "+val);

Now, to convert it to Long object is not a tiresome task. Include the same long value while creating a new Long object −

// object Long myObj = new Long(val); System.out.println("Long object: "+myObj);

The following is the complete example −

Example

Output

long primitive: 45 Long object: 45

Samual Sam

Learning faster. Every day.

  • Related Articles
  • Convert Long to numeric primitive data types in Java
  • How to convert Long array list to long array in Java?
  • Convert String to Long in Java
  • Convert from String to long in Java
  • Convert Java Boolean Primitive to Boolean object
  • How to Convert Int to Long in Java?
  • Convert short primitive type to Short object in Java
  • Convert byte primitive type to Byte object in Java
  • Convert Long into String using toString() method of Long class in java
  • Convert double primitive type to a Double object in Java
  • Convert Decimal to Int64 (long) in C#
  • How to convert String to Long in Kotlin?
  • C# program to convert string to long
  • Program to convert Primitive Array to Stream in Java
  • Java Program to convert String to short primitive

Источник

Читайте также:  Php replace to filename
Оцените статью