Question: Which code to check whether the following string is not empty, then, If it is not empty, prints the last 5 characters of the string.

Which code to check whether the following string is not empty, then, If it is not empty, prints the last 5 characters of the string. Stringstr="Thisstringisnotempty"; if(!str.isEmpty()) \{ System.out.println(str.substring(str.length()-5, str.length())); \} if(str.isNotEmpty()) \{ System.out.println(str.substring(str.length()-5, str.length()-1)); \} if(!str.empty()) \{ System.out.println(str.substring(str.length()-6, str.length())); \} if(!str.isEmpty()) \{ System.out.println(str.substring(str.length()-6, str.length()-1)); \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
