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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:19:09+00:00 2026-06-17T00:19:09+00:00

I have created a class called Placeslist when i try to make a list

  • 0

I have created a class called Placeslist when i try to make a list of Placeslist and save objects in it i got Android.java.lang.NullPointerException
This is placeslist class

public class Placeslist {

     @Key
     public String status;

     @Key
        public String id;
        @Key
        public String name;
        @Key
        public String reference;

        @Key
        public double lat;

        @Key
        public double lon;

     public Placeslist(String status,String id,String name,String reference,double lat,double lon) {
        // TODO Auto-generated constructor stub
            this.status=status;
            this.id=id;
            this.name=name;
            this.reference=reference;
            this.lat=lat;
            this.lon=lon;

    }

and this is the code when i try save an object in the list

Placeslist placeslist=null;

            String data = EntityUtils.toString(response.getEntity());
            JSONObject jsonObj = new JSONObject(data);
            List<Placeslist>places=null;
            JSONArray results = jsonObj.getJSONArray("results");
            for (int i = 0; i < results.length(); i++) {
                JSONObject result = results.getJSONObject(i);

                String name = result.getString("name");
                String id = result.getString("id");
                String reference = result.getString("reference");
                JSONObject latitudes = result.getJSONObject("geometry")
                        .getJSONObject("location");
                double lon = latitudes.getDouble("lng");
                double lat = latitudes.getDouble("lat");
                placeslist=new Placeslist("OK", id, name, reference, lat, lon);
                places.add(placeslist);

            }
  • 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-17T00:19:10+00:00Added an answer on June 17, 2026 at 12:19 am

    You are missing:

    places = new ArrayList<PlacesList>();
    

    or

    places = new LinkedList<PlacesList>();
    

    List is an interface and cannot be used directly to create an object. A child class should be used instead.

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

Sidebar

Related Questions

In Java, I have created a class called Writer that extends It is initialized
Working on my assignment for Java and I have created a class called Triangle.
I have created a Java class called Rectangle that has the two instance variables
So I have created a List of a Custom Class called FinalPixel , and
I have created a class called Class1, and in another module, I want to
I have created a class library called AddServiceLibrary in which I have a method
I have created my own button class called custom_btn. I created it on the
I have a peculiar problem. I created a normal Objective C class called SampleTable.
I have an entity called File, I created a partial class with a property
I have created a factory class called AlarmFactory as such... 1 class AlarmFactory 2

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.