SyntaxFix
Write A Post
Hire A Developer
Questions
If you will use Regex, it already has a predefined character class "\S" for any non-whitespace character.
!str.matches("\\S+")
tells you if this is a string of at least one character where all characters are non-whitespace