Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Long Wrapper Class

Posted By: Ethan Bouchard     Category: Java     Views: 5671

This article explains about Long wrapper class in java.

Long wrapper class is used to wrap primitive data type long value in an object. 

Examples of Long Wrapper Class


Example 1 : Convert long data type value to Long object

public class longToLong
{
  public static void main(String[] args) 
  {
     long i = 100;
 
     Long l = new Long(i);
     System.out.println(l);
 
  }
}

Output
100

This example shows how a long data type value can be converted to Long object.


Example 2 : Convert String to Long object

public class StringToLong
{
  public static void main(String[] args) 
  { 
    Long l1 = new Long("123");
    System.out.println(l1);
 
    String str = "234";
    Long l2 = Long.valueOf(str);
    System.out.println(l2);
  }
}
 

Output
123
234

This example shows how we can convert String object to Long object.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on Long Wrapper Class Or get search suggestion and latest updates.

Ethan Bouchard
Ethan Bouchard author of Long Wrapper Class is from Montreal, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!