Created
June 18, 2017 17:33
-
-
Save medmek/b4f91cf4997d0d6a716e55bf643ee86e to your computer and use it in GitHub Desktop.
Day 16: Exceptions - String to Integer Hackerrank java7
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.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
String S = in.next(); | |
try{ | |
Integer I = Integer.parseInt(S); | |
System.out.print(I); | |
}catch(NumberFormatException e){ | |
System.out.print("Bad String"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment