Logo

Programming-Idioms

History of Idiom 110 > diff from v27 to v28

Edit summary for version 28 by Debaran:
New Java implementation by user [Debaran]

Version 27

2019-02-02, 02:47:41

Version 28

2019-02-02, 02:48:56

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Code
boolean blank = s.trim().isEmpty();
Comments bubble
Use strip (Java 11) instead of trim for Unicode-awareness, or more simply use isBlank (Java 11)