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

  • Home
  • SEARCH
  • 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 8260537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:07:21+00:00 2026-06-08T03:07:21+00:00

Im declaring from a big list of custom, multiple level, objects (here called venueCounter)

  • 0

Im declaring from a big list of custom, multiple level, objects (here called venueCounter) a simple array of custom objects, with just the information needed for filling a list. I do this because its easier to sort my list and create sections in my list.

But when i try it i get a nullpointerexception. I think that is very weird, because when i tried to fill a stringArray it worked fine. Here is my code that fails:

 ListData ld[]= new ListData[venueCounter.size()];
     int selectedPic;
     JJsonResponse e;
     for(int i=0;i < venueCounter.size() ;i++){
         selectedPic = 0;
         e = venueCounter.get(i);
         ld[i]= null;//           data in listdata object   
         ld[i].name=e.venue.name;
         ld[i].tip_nl=e.venue.tip;
         ld[i].tip_en=e.venue.tip_en;
         ld[i].venueID=e.venue.id;
         // foto uitkiezien
         if (e.venue.venue_photos.isEmpty() == false){ // there is a picture
            for(int j=0; j < e.venue.venue_photos.size() ;j++){ // use user selected picture
                 if(e.venue.venue_photos.get(j).selected == true){ 
                     selectedPic = j;
                 }
                ld[i].photoUrl=e.venue.venue_photos.get(selectedPic).medium;
             }
         }else
             {
             ld[i].photoUrl="url for when there is no url";
           }

         Log.i("url nr. " + String.valueOf(i), ld[i].photoUrl);
     }

and the line with the error is:

ld[i].name=e.venue.name;

But the strange thing is, that when i declare a string array and fill it just the same:

String name[]=new String[venueCounter.size()];

and further in the code

name[i]=e.venue.name;

everything just works fine! But i want this array of listdata, so i can put it in my adapter and just work with it.
Does anyone knows why my code fails and what im doing wrong?

  • 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-08T03:07:22+00:00Added an answer on June 8, 2026 at 3:07 am

    I think the main problem here is the line with

     ld[i]= null;
    

    If you make it null it wont be able to save any data. You should do a new ListData()… instead of the null.

    It works with Strings because whenever you make a string equal to another, java creates the new object and so on.

    Hope I have explained it correctly.

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

Sidebar

Related Questions

is declaring/initializing primitives the same as creating new objects? from what i know when
I'm receiving an exception like cannot convert from 'List' to 'string' when i'm declaring
I'm declaring a simple database class that includes an array of prepared statement, but
It is well-known that declaring objects with JSON notation makes them inherit from (or,
I'm declaring an array of primitives on one of my objects, and cannot seem
I have come to know from book that for declaring a structure variable it
I have acquired the habit of declaring reused variables outside loops from having worked
Is the following method wrong way of declaring namespace in Javascript? It is from
I'm coming from a C++ background to python I have been declaring member variables
I'm passing a bool from one form to another, I have tried declaring 'Private

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.