Scanner useRadix() method in Java with Examples Last Updated : 10 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The useRadix(radix) method of java.util.Scanner class sets this scanner's default radix to the specified radix. A scanner's radix affects elements of its default number matching regular expressions. Syntax: public Scanner useRadix(int radix) Parameters: The function accepts a mandatory parameter radix which specifies the radix to use when scanning numbers. Return Value: The function returns this scanner object. Exceptions: If the radix is less than Character.MIN_RADIX or greater than Character.MAX_RADIX, then an IllegalArgumentException is thrown. Below programs illustrate the above function: Program 1: Java // Java program to illustrate the // useRadix() method of Scanner class in Java import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { String s = "Geeksforgeeks has Scanner Class Methods"; // create a new scanner // with the specified String Object Scanner scanner = new Scanner(s); // print the line of the scanner System.out.println("String:\n" + scanner.nextLine()); // display the Old radix System.out.println("\nOld Radix: " + scanner.radix()); // change the radix // of the scanner to 12 scanner.useRadix(12); // display the new radix System.out.println("\nNew Radix: " + scanner.radix()); // close the scanner scanner.close(); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } Output: String: Geeksforgeeks has Scanner Class Methods Old Radix: 10 New Radix: 12 Program 2: Exception demonstrated Java // Java program to illustrate the // useRadix() method of Scanner class in Java import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { String s = "Geeksforgeeks has Scanner Class Methods"; // create a new scanner // with the specified String Object Scanner scanner = new Scanner(s); // print the line of the scanner System.out.println("String:\n" + scanner.nextLine()); // display the Old radix System.out.println("\nOld Radix: " + scanner.radix()); // change the radix // of the scanner to 64 scanner.useRadix(64); // display the new radix System.out.println("\nNew Radix: " + scanner.radix()); // close the scanner scanner.close(); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } Output: String: Geeksforgeeks has Scanner Class Methods Old Radix: 10 Exception thrown : java.lang.IllegalArgumentException: radix:64 Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#useRadix(int) Comment More infoAdvertise with us Next Article Scanner useRadix() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java - util package Java-I/O Java-Functions Practice Tags : Java Similar Reads Scanner skip() method in Java with Examples skip(Pattern pattern) The skip(Pattern pattern) method of java.util.Scanner class skips input that matches the specified pattern, ignoring the delimiters. The function skips the input if an anchored match of the specified pattern succeeds it. Syntax: public Scanner skip(Pattern pattern) Parameters: 5 min read Scanner useLocale() method in Java with Examples The useLocale() method of java.util.Scanner class sets this scanner's locale to the specified locale. Syntax: public Scanner useLocale(Locale locale) Parameters: The function accepts a mandatory parameter locale which specifies a string specifying the locale to use. Return Value: The function return 2 min read Scanner toString() method in Java with Examples The toString() method of java.util.Scanner class returns the string representation of this Scanner. The exact format is unspecified. Syntax: public String toString() Return Value: This function returns the string representation of this scanner. Below program illustrates the above function: Program 1 1 min read Scanner useDelimiter() method in Java with Examples useDelimiter(Pattern pattern) The useDelimiter(Pattern pattern) method of java.util.Scanner class sets this scanner's delimiting pattern to the specified pattern. Syntax: public Scanner useDelimiter(Pattern pattern) Parameter: The function accepts a mandatory parameter pattern which specifies a deli 2 min read Reader ready() method in Java with Examples The ready() method of Reader Class in Java is used to check whether this Reader is ready to be read or not. It returns a boolean which states if the reader is ready. Syntax: public void ready() Parameters: This method does not accepts any parameters Return Value: This method returns a boolean value 3 min read Like