Parse long value from string

ReturnMethodSummary
static longparseLong(String s)Parses the string argument as a signed decimal long.
static longparseLong(String s, int radix)Parses the string argument as a signed long in the radix.
static LongvalueOf(long l)Returns a Long instance representing the specified long value.
static LongvalueOf(String s)Returns a Long object holding the value of the specified String.
static LongvalueOf(String s, int radix)Returns a Long holding the value from the String with the radix.

public class Main {
  public static void main(String[] args) {
    System.out.println(Long.parseLong("12345"));

  }
}

The output:


12345

To convert or parse string with radix,


public class Main {
  public static void main(String[] args) {
    System.out.println(Long.parseLong("10",8));

  }
}

The output:


8
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.