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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:46:53+00:00 2026-05-20T09:46:53+00:00

I have searched and searched for a solution to this problem, but it seems

  • 0

I have searched and searched for a solution to this problem, but it seems no-one else is experiencing it. Here’s a description:

I’m creating a tile-based game with some co-programmers. We use a database class to do any and all loading of files and images. Everything works out just wonderfully until my Mac suddenly throws a NullPointerException at my face. The weird thing is it works on another dude’s Mac (same model and everything) and it worked just fine on my computer a few minutes before the error. Nothing has been changed in the meantime.

This has happened before, and back then I re-installed the OS which sorted the problem, so it sounds like a tweak in either Eclipse (which I’m using as IDE) or MacOS. Anyone got any ideas?

The project can be found on:
https://github.com/Gadamagaska/Quantum-Man

My stack-trace:

Exception in thread "main" java.lang.NullPointerException
    at entities.Level.getTile(Level.java:24)
    at database.Database.getTile(Database.java:206)
    at core.FoffyMain.drawBottomTiles(FoffyMain.java:82)
    at core.FoffyMain.draw(FoffyMain.java:64)
    at core.Core.gameLoop(Core.java:58)
    at core.Core.run(Core.java:34)
    at core.FoffyMain.main(FoffyMain.java:28)
  • 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-20T09:46:54+00:00Added an answer on May 20, 2026 at 9:46 am

    you could have checks like this

    public int getTile(int layer, int x, int y){
        if(layers!=null && layers.length > layer && layers[layer].length > y && layers[layer][y].length > x)
        {
            return layers[layer][y][x];
        }
        return -1;
    }
    

    or simple handle the null pointer exception

    public int getTile(int layer, int x, int y) {
        try{
    
        return layers[layer][y][x];
        }
        catch(NullPointerException npe)
        {
            return -1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched google and SO for a solution to this problem but have not
I have searched extensively on this, but cannot find the solution to my problem.
I have searched for a general solution to this but only find answers to
I have searched online for a solution, but have yet to find one that
I have searched the web but I cannot find the solution to my problem.
I've searched for an answer and no solution seems to fix this problem, so
I have searched around Google and StackOverflow trying to find a solution to this,
I searched for an implementation of std::map runtime ordering and have found this solution:
I have searched for hours now and haven't found a solution for my problem.
I have searched the web and have found no definitive solution, so here goes:

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.