Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

摘了一段读int的,从这里看,异常是一种,另一种就是用hasNextInt函数

Posted by hawk at 2005-01-12 16:50:11
In Reply To:你看scanner的帮助,难道会没有? Posted by:hawk at 2005-01-12 16:39:31
hasNextInt
public boolean hasNextInt(int radix)Returns true if the next token in this scanner's input can be interpreted as an int value in the specified radix using the nextInt() method. The scanner does not advance past any input. 

Parameters:
radix - the radix used to interpret the token as an int value 
Returns:
true if and only if this scanner's next token is a valid int value 
Throws: 
IllegalStateException - if this scanner is closed

--------------------------------------------------------------------------------

nextInt
public int nextInt()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. 


Returns:
the int scanned from the input 
Throws: 
InputMismatchException - if the next token does not match the Integer regular expression, or is out of range 
NoSuchElementException - if input is exhausted 
IllegalStateException - if this scanner is closed

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator