Continue: Lab 7: Arrays
Practice with 2D arrays. Given the following code:
Line 1: Card[][] cards;
Line 2: cards = new Card[3][];
Line 3: System.out.println("cards.length = " + cards.length);
Line 4: cards[0] = new Card[2];
Line 5: cards[1] = new Card[4];
Line 6: cards[2] = new Card[3];
Line 7: for (int i=0; i < cards.length;i++) {
Line 8: System.out.println("i="+i+": cards[i].length = " + cards[i].length);
Line 9: for (int j=0; j < cards[i].length; j++) {
Line 10: cards[i][j] = new Card(i*j);
Line 11: System.out.println(" j="+j+": cards[i][j] = " + cards[i][j]);
Line 12: }
Line 13: }
Do the following:
System.out.println(cards[0][0]);
System.out.println(cards[0][0].toString());
ArrayLists:
Reading and Writing Files - Sample Netbeans projects:
File
Ascii (text) file vs binary file Opening a file Closing a file White space |
Exception Throwing an Exception Catching an Exception try-catch Delimiter |