@@ -124,6 +124,14 @@ public interface Stream<T> extends Iterable<T> {
124124 */
125125 public Stream <T > take (int count );
126126
127+ /**
128+ * Skips a specified number of contiguous elements from the start of a sequence then returns remaining elements.
129+ *
130+ * @param count The number of elements to skip.
131+ * @return An Stream of type T that contains the elements after the number of elements skipped from the start of the input sequence.
132+ */
133+ public Stream <T > skip (int count );
134+
127135 /**
128136 * Returns distinct elements from a sequence by using the object {@code equals()} to compare values.
129137 *
@@ -219,18 +227,37 @@ public interface Stream<T> extends Iterable<T> {
219227 /**
220228 * Returns the first element of a sequence.
221229 *
222- * @return The first element in the specified sequence or null if the sequence is empty.
230+ * @return The first element in the specified sequence.
231+ * @throws java.util.NoSuchElementException if the sequence is empty.
223232 */
224233 public T first ();
225234
226235 /**
227236 * Returns the first element in a sequence that satisfies a specified condition.
228237 *
229238 * @param predicate A function to test each element for a condition.
230- * @return The first element in the sequence that passes the test in the specified predicate function or null if none does.
239+ * @return The first element in the sequence that passes the test in the specified predicate function.
240+ * @throws java.util.NoSuchElementException if no element matches the sequence.
231241 */
232242 public T first (Predicate <T > predicate );
233243
244+ /**
245+ * Returns the last element of a sequence.
246+ *
247+ * @return The last element in the specified sequence.
248+ * @throws java.util.NoSuchElementException if the sequence is empty.
249+ */
250+ public T last ();
251+
252+ /**
253+ * Returns the last element in a sequence that satisfies a specified condition.
254+ *
255+ * @param predicate A function to test each element for a condition.
256+ * @return The last element in the sequence that passes the test in the specified predicate function.
257+ * @throws java.util.NoSuchElementException if no element matches the sequence.
258+ */
259+ public T last (Predicate <T > predicate );
260+
234261 /**
235262 * Returns the only element of a sequence, or a default value if the sequence is empty; this method throws
236263 * an exception if there is more than one element in the sequence.
0 commit comments