Skip to content

Instantly share code, notes, and snippets.

View reddy-priyatham's full-sized avatar

kethireddy priyatham reddy reddy-priyatham

View GitHub Profile
filter() :- Filters elements based on a predicate stream.filter(x -> x > 10)
map() :- Transforms each element stream.map(String::toUpperCase)
flatMap() :- Flattens nested structures stream.flatMap(List::stream)
distinct() :- Removes duplicates stream.distinct()
sorted() :- Sorts elements stream.sorted()
peek() :- Performs action without modifying the stream stream.peek(System.out::println)
limit() :- Limits the number of elements stream.limit(5)
skip() :- Skips the first N elements stream.skip(3)
forEach() :- Applies an action to each element stream.forEach(System.out::println)
collect() :- Converts stream to a collection or summary stream.collect(Collectors.toList())