Java Utility Library

Java Scanner - radix() Method



The java.util.Scanner.radix() method returns the scanner's default radix.

Syntax

public int radix()

Parameters

No parameter is required.

Return Value

Returns default radix of the scanner.

Exception

NA.

Example:

In the example below, the java.util.Scanner.radix() method is used to find the default radix of the scanner.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {

    //String to scan
    String MyString = "Hello World 10 + 20 = 30.0";

    //creating a Scanner
    Scanner MyScan = new Scanner(MyString);

    //print a line from the Scanner
    System.out.println(MyScan.nextLine());

    //print the default radix of the Scanner
    System.out.println(MyScan.radix()); 

    //close the Scanner
    MyScan.close();      
  }
}

The output of the above code will be:

Hello World 10 + 20 = 30.0
10

❮ Java.util - Scanner