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 624171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:10:18+00:00 2026-05-13T19:10:18+00:00

This may be a little unconventional way of asking for help but my code

  • 0

This may be a little unconventional way of asking for help but my code is running into null pointer runtime errors but the scope of the runtime error is too big to post onto stackoverflow. I really want to figure this out so would it be possible for me to email one of you my code to figure out what is wrong? I know runtime errors tell the specific line number it’s tripping on but I honestly can’t make heads or tails why it’s happening there. Thank you very much!!

Stack trace:

java.lang.NullPointerException
    at Maze.getNumRandOccupants(Maze.java:118)
    at P4TestDriver.testMaze(P4TestDriver.java:995)
    at P4TestDriver.main(P4TestDriver.java:116)
    at __SHELL8.run(__SHELL8.java:7)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at bluej.runtime.ExecServer$3.run(ExecServer.java:814)
java.lang.NullPointerException
    at Maze.addRandomOccupant(Maze.java:130)
    at P4TestDriver.testMazeReadWrite(P4TestDriver.java:1071)
    at P4TestDriver.main(P4TestDriver.java:127)
    at __SHELL8.run(__SHELL8.java:7)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at bluej.runtime.ExecServer$3.run(ExecServer.java:814)
  • 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-05-13T19:10:18+00:00Added an answer on May 13, 2026 at 7:10 pm

    From your comment:

    public int getNumRandOccupants() { return randOccupants.size(); }
    

    Because this is at the top of your stack trace, it means that the randOccupants field is null at the time this method is called.

    Also, if you are getting another NPE at addRandomOccupant, the same collection is probably null there, too. You likely have simply forgotten to construct the collection.

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

Sidebar

Related Questions

this may seem a little odd, but it would make for a convenient way
I know this may sound silly little bit, but there is no other way
I realize something like this has been asked, but this may be a little
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This problem may be a little broad, but I'm going to go ahead and
This may be a stupid question but I have a code with the following
This may seem a little upside down faced, but what I want to be
This may be a little subjective, but I have often found that it can
This may be little weird, but I want to persist only the scalar properties
This may be a little confusing but I having some trouble. My goal is

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.