Convert String to Long Type - Java Language Basics

Java examples for Language Basics:long

Description

Convert String to Long Type

Demo Code


public class Main {
 
  public static void main(String[] args) {
    //1. Construct Long using constructor.
    Long lObj1 = new Long("100");
    System.out.println(lObj1);//from w ww  . j  av a  2  s .co m
   
    //2. Use valueOf method of Long class. This method is static.
    String str = "100";
    Long lObj2 = Long.valueOf(str);
    System.out.println(lObj2);
   
  }
}

Result

Suggest JVM to Run Object Finalization Example


Related Tutorials