splitAsStream() method of a Pattern class used to return a stream of String from the given input sequence passed as parameter around matches of this pattern.this method is the same as the method split except that what we get back is not an array of String objects but a stream. If this pattern does not match any subsequence of the input then the resulting stream has just one element, namely the input sequence in string form.
public Stream<String> splitAsStream(CharSequence input)
Parameters: This method accepts a single parameter CharSequence which represents character sequence to be split.
Return value: This method returns a stream of strings computed by splitting the input around matches of this pattern.
Below programs illustrate the splitAsStream() method:
Welcome to for
aa bb cc dd
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.