You are on page 1of 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