Java.lang.Long.valueOf() Method


Description

The java.lang.Long.valueOf(long l) method returns a Long instance representing the specified long value l.

Declaration

Following is the declaration for java.lang.Long.valueOf() method

public static Long valueOf(long l)

Parameters

l − This is a long value.

Return Value

This method returns a Long instance representing l.

Exception

NA

Example

The following example shows the usage of java.lang.Long.valueOf() method.

package com.tutorialspoint;

import java.lang.*;

public class LongDemo {

   public static void main(String[] args) {

      Long l = new Long(30);
   
      // returns a Long instance representing the specified long value 
      System.out.println("Value = " + l.valueOf(27666));
   }
}  

Let us compile and run the above program, this will produce the following result −

Value = 27666
java_lang_long.htm
Advertisements