這串代碼有沒有問題??建造的時候一直報錯,第六行為非法的表達式開始
public?class?Telphone?{ ????????public?static?void?main(String[]?args)?{ ????????float?screen; ????????float?mem; ????????float?cpu; ????????void?call(){ ????????????????????????System.out.println("hello,World!"); ????????????????} ?????????void?sendMessage(){ ????????????????System.out.println("發短信"); ????????????????} ????????} }
2021-01-07
所有的方法都要放在main外的
2020-02-25
方法中不能定義方法????
2020-02-07
float? cpu; 后面加個}即可。
2020-01-15
public static void main(String[] args){
}本身便是一個方法,方法是不能寫在方法中的。
2019-12-22
public class Telphone {
? ? ? ? public static void main(String[] args) {
? ? ? ? float screen;
? ? ? ? float mem;
? ? ? ? float cpu;
? ? ? ? Telphone dex=new Telphone();
? ? ? ? dex.call();
? ? ? ? dex.sendMessage();
? ? ? ? }
? ? ? ? public void call(){
? ? ? ? ? ? System.out.println("hello,World!");
? ? }
? ? ? ? ?public void sendMessage(){
? ? ? ? ?System.out.println("發短信");
? ? }
}
方法寫的位置不對,應該寫在大括號外面。