In this program, we will create two string variables and check created string is empty or not using the empty?() method and print the appropriate message. The empty?() method is used to check a string is empty or not. It returns true, if the string is empty otherwise it returns false.
Program/Source Code:
The source code to check given string is empty or not is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created 2 string variables Str1, Str2 that are initialized with "Hello", "". Then we used empty?() method to check created strings are empty or not and print the appropriate message.
need an explanation for this answer? contact us directly to get an explanation for this answer