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; } }