为什么 NetBeans 找不到我的主类? [英] Why wont NetBeans find my main class?

查看:77
本文介绍了为什么 NetBeans 找不到我的主类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试让 net beans 找到我的主类,我认为这是我让它输出所有 3 个区域的部分.根据学校的说法,我已经正确编码了它,但是如果有人能指出我的错误并告诉我如何修复它,net beans 和 eclipse 拒绝运行它,我会喜欢它,谢谢.

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));

            }
        }
    }
}
}

推荐答案

你的 main 方法应该是 static

Your main method should be static

public static void main(String[] ar)

当JVM调用主类时,它不会创建类的实例,它只是加载类并调用static main()方法

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

这篇关于为什么 NetBeans 找不到我的主类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆