Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would you change the list=temp; line ONLY so that theoutput would read Apu F

ID: 3613113 • Letter: H

Question

How would you change the list=temp; line ONLY so that theoutput would read Apu Flanders Homer ?
public class Reverse { public static void main(String[] args) { String[] simpsons = {"Homer","Flanders","Apu"}; reverse(simpsons); System.out.println(simpsons[0]+" " + simpsons[1]+" " +simpsons[2]); }
public static void reverse(String[] list) { String[] temp = new String[list.length]; for(int i=0;i<list.length;i++) { temp[i]=list[list.length-i-1]; } list=temp; } } How would you change the list=temp; line ONLY so that theoutput would read Apu Flanders Homer ?
public class Reverse { public static void main(String[] args) { String[] simpsons = {"Homer","Flanders","Apu"}; reverse(simpsons); System.out.println(simpsons[0]+" " + simpsons[1]+" " +simpsons[2]); }
public static void reverse(String[] list) { String[] temp = new String[list.length]; for(int i=0;i<list.length;i++) { temp[i]=list[list.length-i-1]; } list=temp; } }

Explanation / Answer

//Hope this will help you public class Reverse { public static void main(String[] args) { String[] simpsons = {"Homer","Flanders","Apu"}; reverse(simpsons); System.out.println(simpsons[0]+" " + simpsons[1]+" " +simpsons[2]); } public static void reverse(String[] list) { String[] temp = new String[list.length]; for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote