พัฒนา web application ด้วย Java

java stream



# Terminal Operator

 //forEach - Perform an action for each element in the stream

// forEachOrdered(Consumer action)

//collect - Collect the elements of the stream into a collection

//reduce - Reduce the elements of the stream to a single value

//count - Count the number of elements in the stream

//findFirst - Find the first element in the stream

//allMatch - Check if all elements match a condition

//anyMatch - Check if any element matches a condition

// noneMatch

//sum(), min(), max(), average(), count()  -> IntStream, LongStream, and DoubleStream

// toArray

## Intermediate operator

//map - Transform each element in the stream

 //filter - Filter elements based on a condition

//distinct - Remove duplicate elements from the stream

//limit - Limit the number of elements in the stream

//skip - Skip a specified number of elements in the stream

//flatMap - Flatten nested structures in the stream

 // peek - Perform an action on each element without modifying the stream

// sorted(Comparator.comparing(String::length)) - Sort strings by their length

// sorted(Comparator.comparingInt(String::length).reversed()) - Sort strings by their length in reverse order

 // sorted(Comparator.comparing(String::toLowerCase)) - Sort strings case-insensitively


java stream java stream Reviewed by Mr.Boonchai on มีนาคม 10, 2569 Rating: 5

ไม่มีความคิดเห็น:

Thank you

ขับเคลื่อนโดย Blogger.