In our day-to-day programming activities, we usually come across multiple scenarios where we need to check whether a string is empty or not. There are multiple ways to do this check in Java: equals method: str.equals(“”) length method: str.length() == 0 //recommended isEmpty method [From Java 1.6 onward]: str.isEmpty() //recommended The recommended way for empty string check is length() or isEmpty() method. We should never use...
- 05:42
- 2 Comments