Skip to content

Instantly share code, notes, and snippets.

@gidili
Created July 30, 2012 15:10
TryParse Integer in java
public static Integer TryParseInt(String someText) {
try {
return Integer.parseInt(someText);
} catch (NumberFormatException ex) {
return null;
}
}
@ADTC
Copy link

ADTC commented Oct 17, 2014

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 allows TryParseInt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment