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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:15:44+00:00 2026-05-16T00:15:44+00:00

i get NullPointerException at the start of the for where am i going wrong?

  • 0

i get NullPointerException at the start of the for
where am i going wrong?

 public void checkzone(Location loc)
  {

      X = new List<float[]>() {


    }; 
     Y = new List<float[]>() {
    }; 
        X.clear();
        Y.clear();

      float x = (float) loc.getLatitude();
      float y = (float) loc.getLongitude();
     float  A1X[] = {(float) 41.992853, (float) 41.994815, (float) 41.995158, (float)  41.993065};//DOMA
     float  A3X[] = {(float) 41.994594, (float) 41.994595, (float) 41.993744, (float) 41.993747};//OVIE SE TOCNI
     float  A4X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  A5X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  A6X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  B2X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  C11X[] ={(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  C15X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};
     float  C17X[] = {(float) 41.121212, (float) 41.121212, (float) 41.121212, (float) 41.121212};


     float A1Y[] = {(float) 21.411527, (float) 21.411505, (float) 21.4142847, (float) 21.415116};//Doma
     float A3Y[] = {(float) 21.427817, (float) 21.428015, (float) 21.427972, (float) 21.427763};//OVIE SE TOCNI
     float A4Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};
     float A5Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};
     float A6Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};     
     float B2Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};
     float C11Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};
     float C15Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};
     float C17Y[] = {(float) 21.122112, (float) 21.122112, (float) 21.122112, (float) 21.122112};


    X.add(A1X);
    X.add(A3X);
    X.add(A4X);
    X.add(A5X);
    X.add(A6X);     
    X.add(B2X);
    X.add(C11X);
    X.add(C15X);
    X.add(C17X);
    X.add(A1X);

    Y.add(A1Y);
    Y.add(A3Y);
    Y.add(A4Y);
    Y.add(A5Y);
    Y.add(A6Y);
    Y.add(B2Y);
    Y.add(C11Y);
    Y.add(C15Y);
    Y.add(C17Y);
    Y.add(A1Y);

      for(int i=0; i<=X.size();i++)
      {


          if (pointInPolygon(X.get(i).length,X.get(i),Y.get(i),x,y))
          {

                switch (i) {
                case 1:
                    zonefoundsettexts("A1");  
                case 2:
                    zonefoundsettexts("A3");    
                case 3:
                    zonefoundsettexts("A4");    
                case 4:
                    zonefoundsettexts("A5");    
                case 5:
                    zonefoundsettexts("A6");    
                case 6:
                    zonefoundsettexts("B2");
                case 7:
                    zonefoundsettexts("C11");
                case 8:
                    zonefoundsettexts("C15");
                case 9:
                    zonefoundsettexts("C17");


                          }
            }
//            else
       //                 zonefoundsettexts("nozone");

      }




  };
  • 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-16T00:15:44+00:00Added an answer on May 16, 2026 at 12:15 am

    BAD:

    for(int i=0; i<=X.size();i++)
    

    GOOD:

    for(int i = 0, n = X.size(); i < n; i++)
    

    BAD:

               case 1:
                    zonefoundsettexts("A1");  
               case 2:
                    zonefoundsettexts("A3");    
    

    GOOD:

               case 1:
                    zonefoundsettexts("A1");  
                    break;
               case 2:
                    zonefoundsettexts("A3");    
                    break;
    

    also you don’t have to clear() lists just after you create them

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

Sidebar

Related Questions

When I try to call any GL15 function in lwjgl I get A NullPointerException.
It doesn't seem to be working right now. I get a java.lang.NullPointerException I have
Start a new web application using NetBeans 7 on GlassFish 3.1 In index.xhtml body
I'm very new to android, in fact only started yesterday. I managed to get
I'm trying to implement Java server and C client. I get java.lang.NullPointerException when I
I get a NullPointerException when a url passed in webview in an activity (the
I'm working for hours on an error I get, when I want to start
I can't get javax.jms.ConnectionFactory injected into my standalone JMS client. I get a java.lang.NullPointerException
Here is my code: public class Main { public static void main(String[] args) {
Here is my code: MediaPlayer a1,a2,a3...a24; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.a);

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.