MrGamma195
MrGamma195

Reputation: 35

Why wont NetBeans find my main class?

I've been trying to get net beans to find my main class which I'm thinking is the part where I have it output all 3 areas. According to the school I've correctly coded it but net beans and eclipse refuse to run it if anyone can point out my error and show me how to fix it I'd love it thanks.

package shape
public class Shape {

    class circle {

        int r;
        int r1;
        double pi;

        double FindArea(int a, int b, double c) {
            r = a;
            r1 = b;
            pi = c;
            return r * r1 * pi;
        }

        class rectangle {

            int height;
            int width;

            int RFindArea(int d, int e) {
                height = d;
                width = e;
                return width * height;
            }
        }

        class square {

            int s;

            int SFindArea(int f) {
                s = f;
                return s ^ 2;
            }
        }

        class result {

            public void main(String[] args) {
                circle objCircle = new circle();
                System.out.println(objCircle.FindArea(10, 10, 3.14));
                rectangle objRec = new rectangle();
                System.out.println(objRec.RFindArea(20, 15));
                square objS = new square();
                System.out.println(objS.SFindArea(5));

            }
        }
    }
}
}

Upvotes: 1

Views: 97

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240976

Your main method should be static

public static void main(String[] ar)

When JVM invokes main class it doesn't create instance of the class, it just loads the class and invokes static main() method

Upvotes: 1

Related Questions