Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:25:19+00:00 2026-06-01T09:25:19+00:00

This is in Java, cross platform and being debugged on a computer running Ubuntu

  • 0

This is in Java, cross platform and being debugged on a computer running Ubuntu Oneric with OpenJDK installed as my runtime.

I have an EnumSet for checking inside of in a class in a game I’m working on. I have this readout from logcat, from debug aplenty in my constructor:

Tile : passability being set...?
Exception in thread "Thread-1" javax.media.opengl.GLException:java.lang.NullPointerException
    ...
Caused by: java.lang.NullPointerException
    at net.darkglass.map.Tile.addPassability(Tile.java:144)
    ...

Not amusing. Tracking it down, my problem seems to be, entirely, this line:

public void addPassability(Passability type)
{
    this.passability.add(type);
}

By which I mean the body of that function. It is called from the constructor as:

this.addPassability(Passability.AIR);

When the NullPointerException happens. In the body of the Passability Enum Type, I have

public enum Passability
{
    AIR, ALL, GROUND, NONE, SIGHT, SKILL, STRUCTURE, WATER;
}

as, quite literally, the entire enum save package declaration. this.passability is declared

private EnumSet <Passability> passability;

at the beginning of the class definition and I was under the impression that the add() method was inherited as part of the definition of EnumSet in the Java Standard.

I’m self-taught, but I’m not crazy. Either I’ve got something wrong or there’s a better way to do this. Anyone with some useful knowledge out there able to lend a hand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:25:20+00:00Added an answer on June 1, 2026 at 9:25 am

    So you’ve declared the passability variable, but you’ve shown no sign of it being assigned a value other than the default value of null. Perhaps you meant:

    private EnumSet<Passability> passability = EnumSet.noneOf(Passability.class);
    

    An EnumSet is an object, like any other – so unless you explicitly give your variable, it will have the default value of null and when you call add on it, you’ll get a NullPointerException – which is exactly what’s happened here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a free cross platform mock up designer in Java. I have
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
I have this java string: String bla = <my:string>invalid_content</my:string>; How can I replace the
I have this Java code, and I want to do the same thing in
I have this java servlet that grabs information from a form, I need to
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
Note: This question originally applied to Xapian , but due to cross-platform issues and
Is there a reliable, cross-platform way to do IPC (between two JVMs running on
On my cross-platform SWT Java application, I'm using TrayItem's setImages() function to set the
I'm using Selenium Java 2.0b3 . I have this code: ... WebDriver driver =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.