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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:46:44+00:00 2026-06-06T07:46:44+00:00

I tried everything to get this code working, and I hope someone will save

  • 0

I tried everything to get this code working, and I hope someone will save me..

I just want to initialize my Objects Street1 and Street2 which are in commentary right now.

The only way i found to make my code work is to initialize them like this :

Street1 = new Objects[0];
Street2 = new Objects[0];

But i can’t fill my Objects ! I worked fine for days, but when i decided to move into a non-static class, it just gave my that error.. What’s wrong please ?

public class Maps {


int CurrentMapID ;

int CheckedObjetQuantity=0;

Map[] MapList = new Map[5];

Objects[] Street1; 
Objects[] Street2;

Map CurrentMap;


public Maps(){

    CurrentMapID = 1;


    //Street1 = {new Objects(987,1020,1,2),new Objects(985,1036,3,75/*,true,3*/),new Objects(1259,1028,1,3),new Objects(3391,1036,1,1),new Objects(213,1013,102,1)};  // les Objets de la map Street1      (x,y,IDobjet,quantité)
    //Street2 = {new Objects(1891,1011,1), new Objects (1847,1025,101)};

    Street1 = new Objects[0];
    Street2 = new Objects[0];


    MapList[1]= new Map (1,4,2,Street1,(Main.InstallPath+"maps/street.png"),(Main.InstallPath+"maps/fstreet.png"),(Main.InstallPath+"maps/streetcollision.png"),50,800,3600,800);
    MapList[2]= new Map (2,1,3,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);
    MapList[3]= new Map (3,2,4,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);
    MapList[4]= new Map (4,3,1,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);


    CurrentMap = MapList[CurrentMapID];

}

So, this code works, the following won’t work and i don’t know why:

public class Maps {


int CurrentMapID ;

int CheckedObjetQuantity=0;

Map[] MapList = new Map[5];

Objects[] Street1 = {new Objects(987,1020,1,2),new Objects(985,1036,3,75/*,true,3*/),new Objects(1259,1028,1,3),new Objects(3391,1036,1,1),new Objects(213,1013,102,1)};  // les Objets de la map Street1      (x,y,IDobjet,quantité)
Objects[] Street2 = {new Objects(1891,1011,1), new Objects (1847,1025,101)};

Map CurrentMap;


public Maps(){

    CurrentMapID = 1;


    //Street1 = new Objects[0];
    //Street2 = new Objects[0];


    MapList[1]= new Map (1,4,2,Street1,(Main.InstallPath+"maps/street.png"),(Main.InstallPath+"maps/fstreet.png"),(Main.InstallPath+"maps/streetcollision.png"),50,800,3600,800);
    MapList[2]= new Map (2,1,3,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);
    MapList[3]= new Map (3,2,4,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);
    MapList[4]= new Map (4,3,1,Street2,(Main.InstallPath+"maps/street2.png"),(Main.InstallPath+"maps/fstreet2.png"),(Main.InstallPath+"maps/street2collision.png"),50,800,3600,800);


    CurrentMap = MapList[CurrentMapID];

}

It return this error :

Exception in thread "main" java.lang.ExceptionInInitializerError
        at Maps.<init>(Maps.java:11)
        at Main.main(Main.java:73)
Caused by: java.lang.NullPointerException
        at Box.<init>(Box.java:65)
        at Objects.<clinit>(Objects.java:16)
  • 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-06T07:46:46+00:00Added an answer on June 6, 2026 at 7:46 am

    It looks like you want to create an array of Objects objects, right?

    You left out the code to construct the new array before defining its contents:

    Street2 = new Objects[] { new Objects(1891, 1011, 1), new Objects (1847, 1025, 101) };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't get my dojo working. I've tried everything. Here is the code: <!DOCTYPE
Ok, I've tried about near everything and I cannot get this to work. I
I tried everything to debug this one but I can't get to the bottom
I've tried almost everything to get this to work. It is really best explained
I've been working on this all day now, and I just can't get it
I've searched all over and tried everything but I still get: invalid multibyte char
I've searched for help and tried everything on this thread , but still can't
This will take a bit of explanation so I hope I don't lose everyone
I have tried everything and this makes absolutely no sense! I previously had Less.js
I hope my question is describing itself =) I tried to do everything but

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.