Need a simple and basic Java code for this exercise:
Write the following method that returns a new string in which the uppercase letters are changed to lowercase and lowercase letters are changed to uppercase.
public static String swapCase(String s)
In method, swapCase create the variable StringBuilder str = new StringBuilder(s); and use methods in the StringBuilder class to modify str and then return string represented in the StringBuilder object, str.
Write a test program that prompts the user to enter a string and invokes this method, and displays the return value from this method.
Here is a sample run:
Enter a string: i'M HERE
The new string is: I'm here