public?class?Test{
????private?String?name;
????private?String?sxe;
????private?int?age;
????public?void?setName(String?newname){
????????name=newname;
????}
????public?String?getName(){
????????return?name;
????}
????public?void?show(String?name,String?sxe,int?age){
????????System.out.println("走這里沒");
????}
}
class?Su{
????public?static?void?main(String[]?args){
????????Test?hello=new?Test();
????????hello.show("智囊",?"男",?20);
????????hello.setName("煞筆");
????????System.out.println(hello.getName());
????}
}
2017-08-01
代碼沒問題,把你的Su類放到另一個(gè)java文件中,class用public修飾能運(yùn)行,你用的是慕課網(wǎng)自帶的編輯器吧?最好有一個(gè)eclipse
2017-08-03
public class TestThree {
? ?private String name;
? ?private String sxe;
? ?private int age;
? ?public void setName(String newname){
? ? ? ?name=newname;
? ?}
? ?public String getName(){
? ? ? ?return name;
? ?}
? ?public void show(String name,String sxe,int age){
? ? ? ?System.out.println("走這里沒");
? ?
}
? ?public static void main(String[] args){
? ? ? ?TestThree hello=new TestThree();
? ? ? ?hello.show("智囊", "男", 20);
? ? ? ?hello.setName("煞筆");
? ? ? ?System.out.println(hello.getName());
? ?}
}