Which lambda expression can be used to check if a string is empty?

  1. s -> s.isEmpty()
  2. () -> isEmpty()
  3. s => s.empty()
  4. s -> s.size() == 0
Correct answer s -> s.isEmpty()

Explanation

The `isEmpty()` method checks for an empty string.

Update: Admin added a tag on this question

Topics

By Admin · · 47 views