Java Scanner.nextLong(int radix)

Syntax

Scanner.nextLong(int radix) has the following syntax.

public long nextLong(int radix)

Example

In the following code shows how to use Scanner.nextLong(int radix) method.


//from   ww  w .  j  a  v  a 2  s  .c  o m
import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

      String s = "java2s.com 1 + 1 = 2.0 true 9000000000000000000000L";

      Scanner scanner = new Scanner(s);

      while (scanner.hasNext()) {
         System.out.println("Not Found :" + scanner.next());
         if (scanner.hasNextLong()) {
            System.out.println("Found :" + scanner.nextLong(20));
         }
      }
      scanner.close();
   }
}

The code above generates the following result.