View Single Post
  #2   Spotlight this post!  
Unread 07-31-2016, 12:34 PM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: FTC NullPointerException

You never initialize rd_hardwareMap

Also next time, the contents of the stack trace would be useful to post

Typically, the 2nd line of a stack trace tells you which line caused the exception. For example, if you have code like
Code:
class MyClass {
	Object thing = null;
	
	public void init() {
		thing.toString();
	}
	
	public static void main (String[] args) {
		new MyClass().init();
	}
}
and you get
Code:
Exception in thread "main" java.lang.NullPointerException
	at MyClass.init(Main.java:5)
	at MyClass.main(Main.java:9)
You know that line 5 caused the error, which is
Code:
thing.toString();
NullPointerExceptions occur when you try to access a field or method of an object that is null. In this case, we try to access a method on thing. That must mean thing is null.

It's also sometimes helpful to use a Java debugger. I'm not sure how FTC programming works but if you have a debugger available, you should use it. It will break (pause the program) on exceptions and let you inspect the contents of all the variables at that point.
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org

Last edited by euhlmann : 07-31-2016 at 12:55 PM.
Reply With Quote