- 265 名前:デフォルトの名無しさん mailto:sage [2007/10/17(水) 13:43:25 ]
- public class Meibo{
private 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); }
|

|