Udostępnij za pośrednictwem


Scanner.NextDouble Method

Definition

Scans the next token of the input as a double.

[Android.Runtime.Register("nextDouble", "()D", "")]
public double NextDouble ();
[<Android.Runtime.Register("nextDouble", "()D", "")>]
member this.NextDouble : unit -> double

Returns

the double 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 double value.

Remarks

Scans the next token of the input as a double. This method will throw InputMismatchException if the next token cannot be translated into a valid double value. If the translation is successful, the scanner advances past the input that matched.

If the next token matches the <i>Float</i> regular expression defined above then the token is converted into a double 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 Double#parseDouble Double.parseDouble. If the token matches the localized NaN or infinity strings, then either "Nan" or "Infinity" is passed to Double#parseDouble(String) Double.parseDouble as appropriate.

Java documentation for java.util.Scanner.nextDouble().

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