java - Parsing user input - getting integers from strings and exception handling -


my application have text box user edit numbers (hopefully)

i using integer.parseint() convert string integer, however, there's chance user not pass in numbers throw exception during parseint(). not sure convention error handling in gwt. work?

int number = -1; try {   number = interger.parseint(inputfromuser); } catch (exception e) {   // error handling telling user try again } 

you on right track. change exception numberformatexception , should fine.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -