java.util.Scanner radix()

Description :

This java tutorial shows how to use the radix() method of Scanner class of java.util package. This method returns the radix this Scanner object is using. This might corresponds to the default value or from the setting of useRadix(radix) method which generally override the default radix.

Method Syntax :

public int radix()

Parameter Input :

[table]
DataType|Parameter|Description
N/A|N/A|N/A
[/table]

Method Returns :

This method simply returns the radix which the Scanner class is using in scanning numbers.

Compatibility Version :

Requires Java 1.5 and up

Exception :

None

Discussion :

The Scanner radix() method is helpful to determine what is the Scanner object has been set in scanning numbers. The default radix can be overridden using the useRadix() method thus if we want to use again the default radix, invoking reset() method will force this Scanner object to use the default.

Make a not that we are using radix to determine what would be the behavior of our Scanner object in dealing with numbers such as using the method nextInt().

Java Code Example :

This java example source code demonstrates the usage of radix() method of Scanner class. Basically this code just  prints the radix that is being used by the Scanner object in dealing with numbers.

Sample Output :

Running the radix() method example source code of Scanner class will give you the following output

java scanner radix() method example

java scanner radix() method example

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :