Java – How to Convert primitive long datatype to Long object?

Problem Statement

You need to convert the primitive long datatype to object in Java.


Use the Long wrapper class to convert the long primitive to Long object as shown below.

public class Main {

    public static void main(String[] args) {

        System.out.println(" Java Tutorials");

        long input1 = 89;

        // Convert primitive long datatype value to Long Object
        Long output = new Long(input1);


The output of the above program is Java Tutorials


%d bloggers like this: