Skip to content

Instantly share code, notes, and snippets.

@kvalv
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save kvalv/99310c33787feab69cf4 to your computer and use it in GitHub Desktop.

Select an option

Save kvalv/99310c33787feab69cf4 to your computer and use it in GitHub Desktop.
void run () throws NumberFormatException{
Scanner scan = new Scanner(System.in);
scan.useDelimiter("[0-9]+");
while ( true ) {
try {
String inputLine = scan.nextLine();
int parseInt = Integer.parseInt(inputLine);
System.out.println("input was: " + Integer.toString(parseInt));
} catch (NumberFormatException e) {
System.out.println( e.toString() );
}
}
}
void run () throws NumberFormatException{
Scanner scan = new Scanner(System.in);
while ( !scan.hasNextInt() ) {
int nextScore = scan.nextInt();
hsc.addResult( nextScore );
}
}
void run () throws NumberFormatException{
Scanner scan = new Scanner(System.in);
scan.useDelimiter("[0-9]+");
try {
while ( true ) {
String inputLine = scan.nextLine();
int parseInt = Integer.parseInt(inputLine);
System.out.println("input was: " + Integer.toString(parseInt));
}
}
catch (NumberFormatException e) {
System.out.println( e.toString() );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment