다음을 통해 공유


Scanner.NextFloat Method

Definition

Scans the next token of the input as a float.

[Android.Runtime.Register("nextFloat", "()F", "")]
public float NextFloat ();
[<Android.Runtime.Register("nextFloat", "()F", "")>]
member this.NextFloat : unit -> single

Returns

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

Remarks

Scans the next token of the input as a float. This method will throw InputMismatchException if the next token cannot be translated into a valid float value as described below. 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 float 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 Float#parseFloat Float.parseFloat. If the token matches the localized NaN or infinity strings, then either "Nan" or "Infinity" is passed to Float#parseFloat(String) Float.parseFloat as appropriate.

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

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