Multiple filters and maps java stream I need to find the odd occurring numbers as a list. For example the below list should give 1 and 2 as output.
Is there a way that I can do it in a better way?
ArrayList&lt;Integer&gt; numbers = new ArrayList&lt;&gt;(Arrays.asList(1,2,2,4,2,4));
List&lt;Integer&gt; OddOcuranceNumbers =
numbers.stream()
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
.entrySet().stream()
.filter(map -&gt; map.getValue() % 2 == 1).map(s -&gt; s.getKey())
.collect(Collectors.toList());
System.out.println(OddOcuranceNumbers);
    }
That depends on how you define better. Better might be more CPU or memory efficient, or it could be fewer bytes in the compiled code, or better parallelization.
But I am going to take a chance on assuming that this code runs on a reasonably normal platform and has no special requirements, and therefore being better generally means better readability.
Readability Improvements
In which case, your code is fine. But we can make it easier to read by splitting it into named steps and wrapping it in a good function.
public List&lt;Integer&gt; getNumbersOccuringOddTimes(final List&lt;Integer&gt; numbers) {
    final Map&lt;Integer, Integer&gt; numberCounts = numbers.stream().collect(groupingBy(Function.identity(), counting()));
    final Predicate&lt;Entry&gt; isOdd = e -&gt; e.getValue() % 2 == 1;
    return numberCounts.entrySet().stream().filter(isOdd).map(Entry::getKey).collect(toList());
}

I've made five minor adjustments to your code to help with readability. I have;

Added a descriptive method name that wraps the steps.
Split the two streams into separate statements.
Used static imports (not shown) for the Collectors functions.
Moved the modulus check into a predicate variable (isOdd) so it can be named.
Swapped out the lambda in .map to a method reference because it is shorter and more descriptive.