0% found this document useful (0 votes)
29 views

Laboratory 4 Data Structures and Algorithm

This document provides instructions for 3 methods to manipulate ArrayLists: 1) A method to add additional numbers to an ArrayList of numbers 2) A method to add a string of asterisks between each string in an ArrayList of strings 3) A method to switch the order of string values in an ArrayList in pairwise fashion

Uploaded by

Marvin Torre
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Laboratory 4 Data Structures and Algorithm

This document provides instructions for 3 methods to manipulate ArrayLists: 1) A method to add additional numbers to an ArrayList of numbers 2) A method to add a string of asterisks between each string in an ArrayList of strings 3) A method to switch the order of string values in an ArrayList in pairwise fashion

Uploaded by

Marvin Torre
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

LABORATORY 4

Data Structures and Algorithm

Name: _____________________

1. Write a method yourArraylist1 that takes an ArrayList of Number as a parameter and that places
additional group of number. Use {1,2,3,4,5} as default array number. The program will accept
additional values and your array list should like this {10,9,8,7,6,1,2,3,4,5,6}. Show your output.
2. Write a method yourArraylist2 that takes an ArrayList of Strings as a parameter and that places a
string of three asterisks "***" in between of every string. For example, suppose that a variable
called list contains the following values: {"this", "is", "lots", "of", "fun", "for", "everyone”} And
then list should store the following values after the call: {"***", "this","***", "is", "***", "lots",
"***", "of", "***", "fun", "***", "for", "***", "everyone"}.
3. Write a method wordSwitch that switches the order of string values in an ArrayList in a pairwise
fashion. Your method should switch the order of the first two values, then switch the order of
the next two, switch the order of the next two, and so on. For example, if the list initially stores
these values: {"are", "handshakes", "hugs", "good", "better", "are"} your method should switch
the first pair, "are", "handshakes" the second pair, "hugs", "good", and the third pair, "better",
"are" to yield this list: {"handshakes", "are", "good", "hugs", "are", "better"}

You might also like