Marko Milenkovic photo

Marko Milenkovic

I'm Marko — a Java backend engineer writing about what actually works: performance benchmarks, JUnit, SQL Server, and JVM internals.
13 posts 1 TIL
Pinned · Now What I'm Doing Now — Last updated: October 2026 Working as a Java backend engineer — SQL Server, Hibernate, JUnit Improving this website: SEO, comments, …
Marko Milenkovic
TIL

TIL: String.isBlank() vs isEmpty()

" ".isEmpty() returns false, but " ".isBlank() returns true — whitespace counts as blank, not empty.

1" ".isEmpty();   // false — length is 1
2" ".isBlank();   // true  — whitespace only (Java 11+)
3"abc".isBlank(); // false

I caught myself writing s.trim().isEmpty() again today. String.isBlank() exists since Java 11 and covers exactly this case — plus it is Unicode-aware, so " \u00A0 ".isBlank() also works where trim() misses non-breaking spaces.

Enjoying these posts?

New Java, SQL Server & testing posts — straight to your inbox.

Load more