Scanner.NextInt Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
NextInt() |
Scans the next token of the input as an |
NextInt(Int32) |
Scans the next token of the input as an |
NextInt()
Scans the next token of the input as an int
.
[Android.Runtime.Register("nextInt", "()I", "")]
public int NextInt ();
[<Android.Runtime.Register("nextInt", "()I", "")>]
member this.NextInt : unit -> int
Returns
the int
scanned from the input
- Attributes
Exceptions
if this Scanner
has been closed.
if input has been exhausted.
if the next token can not be translated into a valid
int
value.
Remarks
Scans the next token of the input as an int
.
An invocation of this method of the form nextInt()
behaves in exactly the same way as the invocation nextInt(radix)
, where radix
is the default radix of this scanner.
Java documentation for java.util.Scanner.nextInt()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
NextInt(Int32)
Scans the next token of the input as an int
.
[Android.Runtime.Register("nextInt", "(I)I", "")]
public int NextInt (int radix);
[<Android.Runtime.Register("nextInt", "(I)I", "")>]
member this.NextInt : int -> int
Parameters
- radix
- Int32
the radix used to interpret the token as an int value
Returns
the int
scanned from the input
- Attributes
Exceptions
if this Scanner
has been closed.
if input has been exhausted.
if the next token can not be translated into a valid
int
value.
Remarks
Scans the next token of the input as an int
. This method will throw InputMismatchException
if the next token cannot be translated into a valid int value as described below. If the translation is successful, the scanner advances past the input that matched.
If the next token matches the <i>Integer</i> regular expression defined above then the token is converted into an int
value as if by removing all locale specific prefixes, group separators, and locale specific suffixes, then mapping non-ASCII digits into ASCII digits via Character#digit Character.digit
, prepending a negative sign (-) if the locale specific negative prefixes and suffixes were present, and passing the resulting string to Integer#parseInt(String, int) Integer.parseInt
with the specified radix.
If the radix is less than Character#MIN_RADIX Character.MIN_RADIX
or greater than Character#MAX_RADIX Character.MAX_RADIX
, then an IllegalArgumentException
is thrown.
Java documentation for java.util.Scanner.nextInt(.*int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.