Created
July 30, 2012 15:10
TryParse Integer in java
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
public static Integer TryParseInt(String someText) { | |
try { | |
return Integer.parseInt(someText); | |
} catch (NumberFormatException ex) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The method should be named
tryParseInt
as this is the method naming convention in Java. This is different from C# where the method naming convention allowsTryParseInt
.