Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-10-2008, 02:28 AM
Member
 
Join Date: Apr 2008
Posts: 1
Scotty Boy is on a distinguished road
iterating through a collection of objects
I'm working on a university project using BlueJ. It involves creating
a GUI that displays nine buttons that each hold a value from 1 to 9. I
need to know how to iterate through the collection of buttons and
return their combined value
(45 in this case).

My array is called gameTile and its initialized as:
gameTile = new Tile[9];
for(int i = 0; i < 9; i++) {
gameTile[i] = new Tile(1+i);
}

When I click one of the nine buttons the value of that button becomes
zero, but if it is not clicked it should retain its value so when i go
through the array I want to add up all the button values that have not
been changed to zero.
My iterator looks like this

Private void totalUp {

Iterator<Tile> totalUp = gameTile[9].iterator ();
while(totalUp.hasNext()) {
System.out.println(totalUp.next(gameTile.value));

}

I appreciate any help in this matter. :-)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating through a HashSet Java Tip Java Tips 0 01-21-2008 05:34 PM
Iterating through ArrayList using For loop Java Tip Java Tips 0 01-20-2008 09:53 AM
Iterating through ArrayList Java Tip Java Tips 0 01-20-2008 09:50 AM
Iterating through result set in JSTL Java Tip Java Tips 0 01-15-2008 04:13 PM
Iterating through result set in JSTL Java Tip Java Tips 0 01-14-2008 10:31 AM


All times are GMT +3. The time now is 10:26 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org