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


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cattle drive exercise" Watch "cattle drive exercise" New topic
Author

cattle drive exercise

Mike Gain
Greenhorn

Joined: Sep 29, 2002
Posts: 2
Hi, I'm trying cattle drive exercise. Below is the code I write for assignment 5. I got a exeption said NullPointerException at line 6.
Can anybody tell me the problem?Thank you.
[ code removed -ds ]
[ September 30, 2002: Message edited by: Dirk Schreckmann ]
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
You instanciate you array 'arr' with the following line:
[ code removed ]
Then you set values with:
[ code removed ]
but the second dimension of your array is never allocated.
You should write something like
[ code removed ]
if you want the same dimension for each row, or
[ code removed ]
if you want different size for each row.
W.
[ September 30, 2002: Message edited by: Dirk Schreckmann ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
pgup down,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
-------------------------
Please do not post code related to Cattle Drive assignments. Also, please don't otherwise share solutions on the forum.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I got a exeption said NullPointerException
That must be because you were trying to improperly use an object reference that didn't yet refer to an object - it referred to null.
Mike Gain
Greenhorn

Joined: Sep 29, 2002
Posts: 2
display name changed.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
You are more than welcome to go to the Cattle Drive forum and post a question. The only requirement is that you do not post code. You may, however, post pseudocode.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
GeeCON Prague 2014
 
subject: cattle drive exercise