We have a long string with numbers or words separated by space. We need to get stream of them. What is a preferred method?
I know two options:
- Arrays(str.split(“ “)).stream();
- new Scanner(str).tokens();
Both return a stream of strings. Which option is better?
Any other methods?