Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > iterating throu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 11 Topic 15994 of 16078
Post > Topic >>

iterating through an array of String's

by thufir <hawat.thufir@[EMAIL PROTECTED] > Apr 20, 2008 at 08:50 AM

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




 11 Posts in Topic:
iterating through an array of String's
thufir <hawat.thufir@[  2008-04-20 08:50:00 
Re: iterating through an array of String's
Roedy Green <see_websi  2008-04-20 10:04:03 
Re: iterating through an array of String's
Thufir <hawat.thufir@[  2008-04-30 03:43:18 
Re: iterating through an array of String's
Roedy Green <see_websi  2008-04-20 10:05:35 
Re: iterating through an array of String's
voorth <voorth@[EMAIL   2008-04-21 03:51:03 
Re: iterating through an array of String's
Lew <lew@[EMAIL PROTEC  2008-04-21 07:12:00 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-21 07:58:23 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-21 10:34:52 
Re: iterating through an array of String's
Ian Kidder <ikidder@[E  2008-04-22 06:44:11 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-23 04:06:25 
Re: iterating through an array of String's
Lew <lew@[EMAIL PROTEC  2008-04-23 00:19:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 1:09:51 CDT 2008.