LongStream.Builder accept(long t) is used to insert an element into the element in the building phase of stream. It accepts an element to the stream being built.
void accept(long t)
Parameters: This method accepts a mandatory parameter t which is the element to input into the stream.
Exceptions: This method throws IllegalStateException when the builder has already transitioned to the built state. It means that the stream has entered the built phase and now no it can’t be changed. Hence no more elements can be accepted into the stream.
Below are the examples to illustrate accept() method:
Stream successfully built 4 5 6 7
Example 2: To illustrate IllegalStateException
Stream successfully built 4 5 6 7 Exception thrown when now accepting element into the stream: java.lang.IllegalStateException
- DoubleStream.Builder accept() method in Java
- Stream.Builder accept() method in Java
- IntStream.Builder accept() method in Java
- HTML | accept Attribute
- Accept system call
- HTML | accept-charset Attribute
- Python | Program to accept the strings which contains all vowels
- Method Class | equals() Method in Java
- Method Class | getExceptionTypes() Method in Java
- Method Class | hashCode() Method in Java
- Method Class | getParameterAnnotations() method in Java
- Method Class | getTypeParameters() Method in Java
- Method Class | isBridge() Method in Java
- Method Class | getDefaultValue() Method in Java
- Method Class | toGenericString() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.