Write a method called collapse that takes in an arraylist


Problem:

Question - Write a method called collapse, that takes in an ArrayList of Strings as a parameter and replaces each pair of strings with a single string that consists of the two initial strings in parenthesis separated by a space. If the list is odd length, the final element is stays unchanged. For examples ["hello", "bye", "plus", "minus", "girl", "boy", "smile"] the method should return ["(hello bye)", "(plus minus)". "(girl boy)", "smile"]

Write the code step by step and explain it.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a method called collapse that takes in an arraylist
Reference No:- TGS0893381

Expected delivery within 24 Hours