Go to Post the usual Canadian thing - Karthik [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 17-01-2017, 22:14
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 161
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: java.lang.NullPointerException

The issue is that when your subsystems are initialized, they get their values for all the RobotMap variables before those variables have been initialized. So you can either
  1. Initialize subsystems after calling RobotMap.init(); or
  2. Call RobotMap.init() in a static block in the RobotMap class; or
  3. Remove RobotMap.init() altogether and initialize its contents inline

What you're basically doing is:

Code:
Object a = null;
Object b = a; // set b to the _current_ value of a, which is null
a = new Object();

...

b.doSomething(); // null pointer exception!
__________________
WPILib
GRIP, RobotBuilder

Last edited by SamCarlberg : 17-01-2017 at 22:16.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi