Alternatively, you can use an Ints method from the Guava library, which in combination with Java 8's Optional, makes for a powerful and concise way to convert a string into an int: import com.google.common.primitives.Ints; int foo = Optional.ofNullable(myString) .map(Ints::tryParse) .orElse(0) More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.