nullelements from ArrayList using java.util.stream.Stream.filter() method.
Java 8 added join() method in
java.lang.String class to join Strings elements, It internally uses StringJoiner class for joining Strings elements.
It has two overloaded versions of join() methods. One accepts CharSequence elements and other accepts Iterable of CharSequence, it means you can pass List of String or an Array of String. Refer below three examples to join String values, list of string and an array of string.
map(n -> n * n)or
map(s -> s.toUpperCase())
Files.lines(Path path)method reads all lines from a file as a stream, and bytes from the file are decoded into characters using the standard charset.
Files.lines()method returns a stream of strings from a specified file. Then further, we use to read each lines and splitting the words with the help of regular expression. Once all the words are separated then extract the distinct words from all the elements of the single stream produced by the flatMap().