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()) {


I appreciate any help in this matter. :-)