Java Scanner radix() method example

HQ ┬╗ Java Tutorial ┬╗ java.util ┬╗ Scanner ┬╗ radix() method example
Java Scanner radix() method example 2018-02-20T12:50:04+00:00

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 :

DataType Parameter Description
N/A N/A N/A

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 :

 

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close