code a calling and called method that reverse their actual and formal parameter names.///java
public class ReverseNames { public static void reverse(String[] arr) { String temp; for (int i = 0; i < arr.length / 2; i++) { temp = arr[i]; arr[i] = arr[arr.length - i - 1]; arr[arr.length - i - 1] = temp; } } public static void print(String[] arr) { for (int i = 0; i < arr.length; ++i) { System.out.print(arr[i] + " "); } System.out.println(); } public static void main(String[] args) { String[] names = {"ronaldo", "messi", "bale", "hazard"}; System.out.print("Original array: "); print(names); reverse(names); System.out.print("Reversed array: "); print(names); } }
Get Answers For Free
Most questions answered within 1 hours.