Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started