Logo

Programming-Idioms

History of Idiom 110 > diff from v53 to v54

Edit summary for version 54 by programming-idioms.org:
[Java] +DemoURL

Version 53

2020-10-10, 21:19:38

Version 54

2020-11-26, 12:13:20

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==null || s.trim().isEmpty();
Code
boolean blank = s==null || s.trim().isEmpty();
Comments bubble
Use strip (Java 11) instead of trim for Unicode-awareness, or more simply use isBlank (Java 11)
Comments bubble
Use strip (Java 11) instead of trim for Unicode-awareness, or more simply use isBlank (Java 11)
Demo URL
https://repl.it/@ProgIdioms/CheerfulAzureEnvironment