DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    92

    ArrayList printout?

    hi. i am at the end of a long weekend of doing nothing but working on a programming assignment.

    i have an ArrayList and want to print out each element. each element is an int array. not sure how to print it out. the relevant code is below. but basically, i have used an iterator to create new arrays in another class. they are collected in my test class and printed out there. i just don't know how to convert it from hash code into something readable. a toString method ? i am sorry to have to ask this, i am just brain dead.

    while (iterator.OneRoll_hasNext()){
    new_pos = (iterator.OneRoll_next());
    oneResult.add(new_pos);
    }
    for (int i =0; i<oneResult.size(); i++){
    System.out.println(oneResult.get(i));
    }
    }


    thanks
    crquick

  2. #2
    Join Date
    Jul 2004
    Posts
    92
    oh, the ArrayList is called OneRoll . . . sorry forgot to mention that.

    crq

  3. #3
    Join Date
    Sep 2004
    Posts
    223
    this page will be perfect fo ryou:

    http://leepoint.net/notes-java/25dat...arraylist.html
    A kram a day keeps the doctor......guessing

  4. #4
    Join Date
    Jul 2004
    Posts
    92
    thanks anyway, but i think there is something wrong with those codes. tried them several different ways and they aren't working.

    a.iterator(); iter.hasNext() {

    that part of the first code is really strange


    and

    System.out.println((String)(iter.get(i)));

    that part of the second code doesn't work with a for loop with no "iter".

    i might just have to turn it in as is. i think it WORKS fine. and it is 1 AM and i just don't have another HOUR to figure this out.

    thanks
    crq

  5. #5
    Join Date
    Sep 2004
    Posts
    223
    i agree, now that I have read it a bit more it doesnt make too much sense
    A kram a day keeps the doctor......guessing

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links