// HACK!!!!
// Create an arrayList and use one of the cool methods for it
import java.util.ArrayList;
public class hack1 {
public static void main (String[] args) {
ArrayList<String> colors = new ArrayList<>();
colors.add("blue");
colors.add("green");
}
}
hack1.main(null);
import java.util.ArrayList;
public class main{
public static void main(String[] args) {
ArrayList<String> color = new ArrayList<String>();
color.add("red apple");
color.add("green box");
color.add("blue water");
color.add("red panda");
for (int i = 0; i < color.size(); i++) {
if (color.get(i).contains("red")) {
color.remove(i);
}
}
for (int i = 0; i < color.size(); i++){
System.out.println(color.get(i) + " ");
}
}
}
/*/
using
if(color.get(i).contains("red"))
iterate through the arraylist and remove all elements that contain the word red in them
/*/
main.main(null);
// Hack #3
// find the sum of the elements in the arraylist
ArrayList<Integer> num = new ArrayList<Integer>();
num.add(5);
num.add(1);
num.add(3);
int count = 0;
for ( int n : num) {
count = count + n;
}
System.out.print(count);