For lab2 at http://members.shaw.ca/Java2611/
I need to load data (which
should be an array of Strings) from DATA -- that's not the assignment,
but it's a requirement that the data is loaded in this particular
fashion. It's supposed to not even really be a problem, because we're
supposed to (from my notes):
hard code the data in the program,
private final String[] GUEST_DATA = {...}
use the constructor
Guest guest1 = new Guest(GUEST_DATA[0]); // will grab row 0
At the moment, I'd be happy to print out DATA, but I want to be able to
iterate through DATA, assigning one row at a time to the data array,
basically doing what's above.
Yes, I'll be reviewing arrays, and it sounds straightforward, but I don't
see why the output is hexadecimal (the object's memory address?).
Any "pointers" would be appreciated:
thufir@[EMAIL PROTECTED]
javac ArrayOfStrings.java
thufir@[EMAIL PROTECTED]
java ArrayOfStrings
[[Ljava.lang.String;@[EMAIL PROTECTED]
cat ArrayOfStrings.java
public class ArrayOfStrings
{
public static String[] data;
private final static String[][] DATA = {
{"00", "01", "02", "03"},
{"10", "11", "12", "13"},
{"20", "21", "22", "23"},};
public static void loadData() {
for (int i=0; i<2; i++) {
data = DATA[0];
System.out.println(DATA);
}
}
public static void main (String[] args) {
loadData();
}
}
thufir@[EMAIL PROTECTED]
thanks,
Thufir


|