Package modernfeatures.streams
Class StreamDistinctLimitSkipExample
java.lang.Object
modernfeatures.streams.StreamDistinctLimitSkipExample
Demonstrates the use of distinct, limit, and skip operations with Java Streams.
This example shows how to:
- Remove duplicates from a list using distinct()
- Limit the output to the first N elements with limit()
- Skip the first N elements with skip()
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
StreamDistinctLimitSkipExample
public StreamDistinctLimitSkipExample()
-
-
Method Details
-
main
Main method demonstrates the stream operations:- Create a list of names with duplicates
- Print unique names using distinct()
- Print the first 3 names using limit()
- Print all names except the first 5 using skip()
- Parameters:
args
- Command-line arguments (not used)
-