-1
class PointInPlane {
    public float x;
    public float y;

    static class CircleInPlane {
        public static float r;  
        public static float xcentr;
        public static float ycentr;

        static void solve(PointInPlane a, PointInPlane b, PointInPlane c) {
            float A = (b.y-a.y)/(b.x-a.x); //geting NullPointerExeption 
            float B = (c.y-b.y)/(c.x-b.x); //probably will get in all next steps
            xcentr = (A*B*(a.y-c.y)+B*(a.x+b.x)-A*(b.x+c.x))/(2*(B-A));
            ycentr = A*(xcentr-a.x)+a.y;
            r = sqrt((pow((a.x - xcentr), 2) + pow((a.y - ycentr), 2))); 
        }
    }
}

So IDK how I can handle this problem. I'm getting NullPointerException when declare float A. I think the problem is that I'm using fields from one class in another or trying to use PointInPlane objects a, b and c with null fields. How this problem could be solved?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
V. Kuz
  • 1

1 Answers1

-1

I'm getting NullPointerExeption when declare float A

This means that your parameter "a" or "b" doesn't refer to any object in memory. This can simply be solved by tracking the variable "a" and "b" to make sure that it refers to an object prior to utilising it.

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126