I'm trying to map and filter my Object[] array to int[] array. Works great, if an object is an int, but throws cast exception if not. I'm wondering if I can somehow attach an try/catch in lambda expression? Here's my code:
b[i] = Arrays.stream(item).mapToInt(e -> (int) e).filter(e -> e % 2 != 0).toArray();
or better way is just to try/catch whole block?