# Using the try{} catch() {}

**URL:** <https://discourse.processing.org/t/using-the-try-catch/26108>\
**Category:** Beginners\
**Created:** [December 10, 2020, 9:39am UTC](https://discourse.processing.org/t/using-the-try-catch/26108 "2020-12-10T09:39:10Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 15, 2020, 7:18pm UTC](https://discourse.processing.org/t/using-the-try-catch/26108/10 "2020-12-15T19:18:36Z")

</div>

> [@neilcsmith](#):
>
> OK, as with everything, almost never - there are cases -

[NumberFormatException](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/NumberFormatException.html) is a very notable case where its `catch () {}` block works as an `if () {}` replacement: 😉

> [@Help determining data type](https://discourse.processing.org/t/help-determining-data-type/26233/3):
>
> This is my Java attempt on that positive number filter challenge: coffee “Program.java”: import java.util.Collection; import java.util.LinkedHashSet; public final class Program { @SafeVarargs static public final String[] filterArray(final String... strs) { if (strs == null || strs.length == 0) return new String[0]; final Collection\<String\> nums = new LinkedHashSet\<\>(); for (final String str : strs) try { Integer.parseUnsignedInt(str); nums.add(str); } c…

> <https://gist.github.com/GoToLoop/bba0c288aaeeb5ef9bb1>

---

_[View the full topic](https://discourse.processing.org/t/using-the-try-catch/26108)._
