Question: 9 10 13 1 // ??? 2 3 4- public class Main { 5 public static void main(String[] args) { 6 ArrayList x = new

 9 10 13 1 // ??? 2 3 4- public classMain { 5 public static void main(String[] args) { 6 ArrayList x

9 10 13 1 // ??? 2 3 4- public class Main { 5 public static void main(String[] args) { 6 ArrayList x = new ArrayList(); 7 x.add( 7 ); 8 x.add( 12 ); X.add( 3 ); X.add( 9 ); 11 x.add( 4 ); 12 x.add( 888 ); replace( x ); 14 System.out.println( x ); // [7, 7, 3, 9, 9, 9] 15 } 16 17 public static void replace( ArrayList list ) { 18 - 1* Complete the replace method so that every even number is replaced with 19 the closest previous odd number. 20 The ArrayList parameter will always have at least one number in it and 21 the first number will always be odd. */ 22 23 24 25 26 } 27 } 28 Complete the replace method so that every even number is replaced with the closest previous odd number. The ArrayList parameter will always have at least one number in it and the first number will always be odd. For example, if the ArrayList is initially [7, 12, 3, 9, 4,888 ) then after the method is called, it will be (7,7, 3, 9, 9,9]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!