Mon: No Technews this week!
ArrayList<String> myList = new ArrayList<String>();
// creates an empty list
ArrayList<int> myNums = new ArrayList<int>();
// NOT ALLOWED
ArrayList<Integer> myNums = new ArrayList<Integer>();
// OK
myList.add("hello");
// adds a single element to the end of the list
ArrayList myList = new ArrayList(Arrays.asList("hi","there","today"));
// adds multiple elements all at once
System.out.println("myList element is " + myList.toString() ) ;
// prints out the list
for (String s: myList) {
System.out.println(s);
}
A few in-class exercises (not to turn in):
2D Arrays Practice with Magic Squares: Do Problemming Exercise P6.12 in the text on p. 267. To make testing easier, it might be good to start by having the values set in the code rather then entered by the user, e.g.
int[][] mySquare = { { 16,3,2,13}, {5, 10, 11, 8},{9, 6, 7, 12},{4, 15,14,1}};
Once this works, write code to prompt the user to enter the numbers.
In Lab:
Follow the instructions: Lab 10: TicTacToe, etc