So I was reading through the java API on oracle just to learn some new stuff and I stumbled upon the StringBuilder class. I did some research on it and noticed many people used it to count words in a String like so.
I was looking at split() and saw the parameter "\\s+". What does that mean? I tested the code and it somehow magically counts the words correctly but baffled me as to how. Any explanations would be great. Thanks!
*Edited: misleading title renamed
String str = "I am a good boy"; String[] words=str.split("\\s+"); System.out.println(words.length);
I was looking at split() and saw the parameter "\\s+". What does that mean? I tested the code and it somehow magically counts the words correctly but baffled me as to how. Any explanations would be great. Thanks!
*Edited: misleading title renamed