小编rks*_*stm的帖子

Java - 圆柱程序 - 无法使用main

我迷路了,我甚至不知道要问什么问题.我有这个程序,应该能够构造一个参数半径和高度的圆柱体.然后它应该能够调用各种方法来获取和设置半径以及输出表面积和体积.我无法通过去因为我不能在我的主要内容中放置任何内容而没有关于静态中使用的静态非静态方法的错误.我甚至都不知道这意味着什么.我实际上将其他人的代码复制到我的编译器中,它给了我同样的错误.我搞砸了一些设置吗?我知道这对Stack Overflow来说可能太过初级,但我现在绝望了.

public class Miller_A03Q1 {

    public static void main(String[] args) {
        Cylinder cylinder1 = new Cylinder(1,17);
        Cylinder cylinder2 = new Cylinder(3,8);
        Cylinder cylinder3 = new Cylinder(2,12);
        Cylinder cylinder4 = new Cylinder (1,14);    
    }

    public class Cylinder{
        private double radius = 0.0;
        private double height= 0.0;
        private double area = 0.0;
        private double volume=0.0;
        private String shape = "cylinder";


        public Cylinder(double r,double h){
            this.radius = r;
            System.out.print(r);
            this.height = h;
            System.out.print(h);

        }
        public double getVolume(){
            double volume = 3.14 * …
Run Code Online (Sandbox Code Playgroud)

java methods static-methods compiler-errors

1
推荐指数
1
解决办法
133
查看次数

标签 统计

compiler-errors ×1

java ×1

methods ×1

static-methods ×1