Java Long valueOf Example

Long class valueOf method example.


Long class valueOf method example. This example shows you how to use valueOf method. This method creates a Long object instance by setting value of long, String  datatype number value in Long object.

Syntax:- valueOf(String s)

Here Is the code:-
/**
 * @(#) ValueOfLong.java 
 *  ValueOfLong class demonstrates the working of valueOf() method of Long class of lang package
 @version 9-May-2008
 @author Rose India Team
 */


public class ValueOfLong {
  public static void main(String args[]) {
    // method sets the value in a Long object or in other way method creates
    // a Long instance of long value
    long value = 25367874;
    System.out.println(Long.valueOf(value)
        " --Long instance value or value of long object ");

    // here the along with valueOf method intValue is also shown
    // method here generates a negative number which nothing value set by
    // intValue method in integer range
    String str = "45345453434";
    System.out.println((Long.valueOf(str)).intValue()
            " --a Long instance value is been set in to integer range by intValue method");
  }

}

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US