Created
April 13, 2013 13:35
-
-
Save aikchun/5378429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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