Question: IN JAVA: Create two STATIC string-manipulation methods in your CS220_Lab10.java template just below the public static void main() { } method/code. Static method 1 takes
IN JAVA: Create two STATIC string-manipulation methods in your CS220_Lab10.java template just below the public static void main() { } method/code. Static method 1 takes in a String as a parameter and returns an array of characters. Given what it does, it would make sense to call this method strToCharArray. In this method, you will need to: Create a character array of the appropriate size (recall the String.length() method) Iterate through the string and copy each character from the string to the character array (again, recall String.length() and String.charAt()) Return the array you created Static method 2 will take in a character array (returns nothing) and simply prints out all of the elements of the array in reverse order (you might call this method reversePrint). Finally, write a main() method that tests all of your code. Your main method should prompt the user to enter in a word (String). That String should be passed into method 1. The returned result of method 1 should be passed into method 2 to fully test both methods. HINT: If youve done everything correctly, you should be able to use one statement in your main method (once youve read in a String from the user into a variable called str) to test your two methods: reversePrint(strToCharArray(str));
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
