jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Null Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Null Arrays" Watch "Null Arrays" New topic
Author

Null Arrays

Sean Magee
Ranch Hand

Joined: Aug 23, 2004
Posts: 69
Hey there!

I am having a problem in one of my programs and i cant seem to get ir right.
I have an array, that holds an object. I go through this array with a for loop checking if any of the slots in the array are null, if a spot is null return true, if the entire array is full, return false. Then it prints everything in the array.

The problem is, this is looped, so when it does it again, its like it was never done the first time and the entire array was set back to null and the values were never there!

Thank you for your help
[ March 06, 2005: Message edited by: Sean Magee ]
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
It's difficult to understand what is happening. Could you post the relevant code for us to have a look at? Remember to use the 'CODE' button before you copy and paste.
Sean Magee
Ranch Hand

Joined: Aug 23, 2004
Posts: 69
I have the code on my laptop, but i try my best to replicate here.

I am having problems with two of my classes, but i think i have to throw the code out for three so you can understand my problem




Ok, so thats the code where the touble lies I think. I have a couple of other classes that I am not showing, like the talk class which mainly deal with the userinput and alos haas a boolean vairable that is assigned by the addCust method, but of course, it never returns false. The talk class also askes which bus the user would like to ride, and how many people the user would like to book, indicated by the passnum and depart integers being passed through the toBooker method in the mainstreet class. However when this
JOptionPane.showMessageDialog(null,""+fullorder);
talk again = new talk();
again.askToPurchase();
executes, it askes the user again which shuttle, which departure, and if you pick the same one as before,

the customer array,
the order array,
and the shuttle array

all have seem to be reset back to null, and did not store the original values that were set by the user.

Can you see what i am doing wrong here?
[ March 06, 2005: Message edited by: Sean Magee ]
Sean Magee
Ranch Hand

Joined: Aug 23, 2004
Posts: 69
Is this enought code to identify the problem??

If it isn;t please let me know so I can make additions accordingly.
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
Hi. Sorry, I forgot about this yesterday. The code you have supplied is insufficient to understand the problem (and some of it doesn't seem valid).

If you post the rest, and point out where in the code you are having a problem, someone will help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null Arrays