-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion206_ArrayList_repeatAll.java
More file actions
46 lines (30 loc) · 1 KB
/
Question206_ArrayList_repeatAll.java
File metadata and controls
46 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package week7_Array_2D_ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
public class Question206_ArrayList_repeatAll {
public static void main(String[] args) {
// olcay // Aug 3, 2020
/*Create a static method that:
is called repeatAL
returns nothing
takes in a single parameter - an ArrayList of Booleans
This method should modify its ArrayList parameter by repeating its ArrayList values.
For example, if the parameter is
(true, false, false)
The modified ArrayList should be
(true, false, false, true, false, false)
*/
ArrayList<Boolean> arr1 = new ArrayList<Boolean>(Arrays.asList(false, true, true));
repeatAL(arr1);
}
public static void repeatAL(ArrayList<Boolean> arr) {
ArrayList<Boolean> newList = new ArrayList<Boolean>();
for(Boolean list : arr) {
newList.add(list);
}
for(Boolean list : arr) {
newList.add(list);
}
System.out.println(newList.toString());
}
}