Go to Post *POP!* I suppose I'll have to change my hair style to the John V-Neun now. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 21-03-2015, 21:33
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Preferences table Null Pointer Exception

Quote:
Originally Posted by RufflesRidge View Post
The sample on that page seems to be missing a line:

prefs = Preferences.getInstance();
You're right! Thats quite funny. Here's the actual code for reference

Code:
package org.usfirst.frc.team40.robot;

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Preferences;

public class Robot extends SampleRobot{

    Preferences prefs;
    double armUpPosition;
    double armDownPosition;
    public void robotInit(){
        prefs = Preferences.getInstance();
        armUpPosition = prefs.getDouble("ArmUpPosition", 1.0);
        armDownPosition = prefs.getDouble("ArmDownPosition", 4.0);
    }
}
On a side note, to follow NetworkTable conventions the method name should be "getNumber" but that is trivial.
 


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 21:12.

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