Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Forked from aikchun/gist:5378429
Created April 13, 2013 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simkimsia/5378461 to your computer and use it in GitHub Desktop.
Save simkimsia/5378461 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.io.*;
public class TestTry{
public static void main(String []args){
int a = 5;
int b = receiveNumberFromUser();
}
public static int receiveNumberFromUser(){
int userInput = "";
try{
Scanner input = new Scanner (System.in);
userInput = input.nextInt();
} catch (InputMismatchException ime){
System.out.println(ime);
}
return userInput; // compiler says this is may not be initialized.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment