以下程序報錯 String 錯了要怎么改?
?public class OK4 {?
?Sring name;//申明變量
name public OK4(){//構(gòu)造方法
?name="愛慕課";?
?System.out.println("name是:");
?}
?public static void main(String[] agrs){ OK4 hello=new OK4(); System.out.println("name"+hello.name);?
}
?}
?public class OK4 {?
?Sring name;//申明變量
name public OK4(){//構(gòu)造方法
?name="愛慕課";?
?System.out.println("name是:");
?}
?public static void main(String[] agrs){ OK4 hello=new OK4(); System.out.println("name"+hello.name);?
}
?}
2016-01-26
舉報
2016-01-26
?public class OK4 {?
? ? ? //修改為靜態(tài):static String name;
? ? ?String name;//申明變量 ?改:sring 單詞錯誤
? ? ? //修改為靜態(tài):public?。螅簦幔簦椋恪。希耍矗ǎ?;
? ? ? ?public OK4(){//構(gòu)造方法
? ? ? ? ? ? name="愛慕課";?
? ? ? ? System.out.println("name是:");
? ? ? ?}
? ? ? ?public static void main(String[] agrs){?
? ? ? ? ? ? OK4 hello=new OK4();?
? ? ? ? ? ? System.out.println("name"+hello.name); //name 非靜態(tài)成員;OK4()非靜態(tài)方法
? ? ? ?}
?}
2016-01-26
public class OK4 {
String name; //申明字符串變量 name
public OK4(){//構(gòu)造方法
name="愛慕課";//初始化塊
System.out.println("通過構(gòu)造方法初始化name");
}
public void show(){
System.out.print("名稱為:"+name);
}
public static void main(String[] arge){
OK4 hello=new OK4();//創(chuàng)建對象
hello.show();// 調(diào)用對象show方法
}
}
2016-01-26
public class OK4 {?
????????public String name ;?????????????????????????????? //申明變量
????????public OK4(){????????????????????????????????????????? //構(gòu)造方法
?????????name="愛慕課";?
?????????System.out.println("name是:");
?????????}
?????????public static void main(String[] agrs){
????????????????OK4 hello=new OK4(); ???????????????
????????????????System.out.println("name"+hello.name);?
????????}
?}