★★ Java の宿題ここで答えます Part 63 ★★
■ このスレッドは過去ログ倉庫に格納されています
0265デフォルトの名無しさん
2007/10/17(水) 13:43:25private String name;
private int age;
private String occupation;
public Meibo(String name, int age, String occupation){
super();
if(age <= 0)throws new IllegalArgumentException("age must be positive");
this.name = name;
this.age = age;
this.occupation = occupation;
}
public String toString(){
return "{ 名前 = " + name + " , 年齢 = " + age + " , 職業 = " + occupation + " }";
}
}
public class Kadai1{
public static void main(String[] args){
Meibo tom = new Meibo("トム", 22, "ニート");
System.out.println(tom);
}
■ このスレッドは過去ログ倉庫に格納されています