Question: 4a) 4b) 4c) List the three key differences between arrays and ArrayLists in Java. (3 marks) Consider a class with a field variable xs

 4a) 4b) 4c) List the three key differences between arrays and ArrayLists  

4a) 4b) 4c) List the three key differences between arrays and ArrayLists in Java. (3 marks) Consider a class with a field variable xs declared by ArrayList xs; Write a method alternating that removes alternating elements from xs. For example, if xs is , after alternating has run, xs will be {"A", "C", "E"). Similarly, if xs is , after alternating has run, xs will be {"A", "C", "E"). (4 marks) // removes alternating elements from the field variable xs public void alternating () Describe how alternating would have to be written if xs were an array variable instead of an ArrayList. What issues might this cause? (3 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

4a The three key differences between arrays and ArrayLists in Java are 1 Size and Flexibility Arrays have a fixed size that is determined at the time ... View full answer

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 Programming Questions!