# Help determining data type

**URL:** <https://discourse.processing.org/t/help-determining-data-type/26233>\
**Category:** Coding Questions\
**Created:** [December 14, 2020, 3:03pm UTC](https://discourse.processing.org/t/help-determining-data-type/26233 "2020-12-14T15:03:24Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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, 5:31pm UTC](https://discourse.processing.org/t/help-determining-data-type/26233/3 "2020-12-15T17:31:54Z")

</div>

This is my Java attempt on that positive number filter challenge: ☕

## “Program.java”:

```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);
    }

    catch (final NumberFormatException notPositiveNumber) {
    }

    return nums.toArray(new String[nums.size()]);
  }
}

```

But b/c I haven’t created an account on [Edabit.com](http://Edabit.com) yet I couldn’t check my code there. 🥴

However I’ve come up with this PDE sketch to test my “Program.java” file on Processing: 😳

```auto
void setup() {
  println(Program.filterArray("1", "2", "a", "b"));
  println(Program.filterArray("1", "a", "b", "0", "15"));
  println(Program.filterArray("1", "2", "aasf", "1", "123", "123"));
  println(Program.filterArray("jsyt", "4", "yt", "6"));
  println(Program.filterArray("r", "5", "y", "e", "8", "9"));
  println(Program.filterArray("a", "e", "i", "o", "u"));
  println(Program.filterArray("4", "z", "f", "5"));
  println(Program.filterArray("abc", "123"));
  println(Program.filterArray("$%^", "567", "&&&"));
  println(Program.filterArray("w", "r", "u", "43", "s", "a", "76", "d", "88"));
  exit();
}

```

```auto
1 2
1 0 15
1 2 123
4 6
5 8 9

4 5
123
567
43 76 88

```

---

_[View the full topic](https://discourse.processing.org/t/help-determining-data-type/26233)._
