GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes output prints null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "output prints null" Watch "output prints null" New topic
Author

output prints null

Nich Kud
Greenhorn

Joined: Nov 14, 2009
Posts: 2
been working on this program for awhile now and part of the output is only printing null so very tired, was wondering if anyone knows how to fix my error.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Nich Kud wrote:part of the output is only printing null


Which part is that?
Nich Kud
Greenhorn

Joined: Nov 14, 2009
Posts: 2
Paul Clapham wrote:
Nich Kud wrote:part of the output is only printing null


Which part is that?



on line 89, it only outputs the last input the user does.
Victor Ewert
Greenhorn

Joined: May 28, 2009
Posts: 17
I'm guessing you are using arrays to track the information, for each time a user adds another item. Part of the problem is, in lines 66 to 75, you keep creating new arrays to add things to which means you are losing the data from the previous iterations. I believe that is why, on line 89 you are only getting the last result.

I see what you are trying to do in lines 66 to 75 is re-adjust the size of the array, since at the beginning of the program you don't know how big the array should be. Instead of using arrays use the ArrayList class which is a List that expands as needed.

Hope that helps,
 
GeeCON Prague 2014
 
subject: output prints null