자바공부하기 62

 

생성자 예

 

public class platoon { //소대

private String name;

public Platoon() { //보통 4분대

name= "Platoon";

}

public Platoon(String name){

this.name=name;

}

public String getPlatoonName(){

return name;

}

public void showPlatoonName(){

System.out.println("The "+name+" platoon. ");

}

}

 

 

 

 

+ Recent posts