[Pogamut-list] automatically driving on the street

michal.bida pogamut-forum at artemis.ms.mff.cuni.cz
Mon Jul 20 17:10:40 CEST 2009


Re: automatically driving on the street

Author: michal.bida

You should always debug your program in some IDE. For Pogamut the best choice is obviously NetBeans. If you would do that, you would receive null pointer exception at Main.java at line 126. :-) You have forgotten to initialize your path2goal variable.

After the definition, which is:

public  ArrayList path2goal = null;

You haven't actually created any ArrayList, so what you have is an empty pointer, which of course, cannot be assigned to with path2goal.add(0, nearestNavPoint); 

The solution: 
public  ArrayList path2goal = new ArrayList ();

In Java you work with pointers to objects - don't forget to create those object. If you are new to Java, there are plenty of tutorials on the web.

Best,
Michal





More information about the Pogamut-list mailing list