问答详情
源自:8-2 如何定义 Java 中的类

怎么会报错尼在eclipse中?

package phone;


public class Phone {


public static void main(String[] args) {

double screen;

double cpu;

double ram;

void call(){

System.out.println("Phone can be used to call");

}

void message(){

System.out.println("Phone can be used to send message");

}

}


}


提问者:lorenzt 2015-05-11 17:00

个回答

  • lorenzt
    2015-05-11 17:28:56

    明白了 定义了个main方法,搞什么鬼。

  • 呵呵呵呵呵呵呵5566
    2015-05-11 17:16:51

    main方法中不能定义方法 只能调用

  • Blackfyre
    2015-05-11 17:16:40

    不能把方法定义到main()方法里面

    public class Phone {


    double screen;

    double cpu;

    double ram;

    void call(){

    System.out.println("Phone can be used to call");

    }

    void message(){

    System.out.println("Phone can be used to send message");

    }

    public static void main(String[] args) {

    }


    }