public class Person{
static String name=new String();
static char gender;
static int number;
public Person(){ }
public Person(String name, char gender,int number){
this.name=name;
this.gender=gender;
this.number=number;
}
public static void showMe(){
String g=new String();
if(gender=='M'){
g="male";
}else if(gender=='F'){
g="female";
}else{
g="unknown";
}
System.out.println(name+"-"+g+"-"+number);
}
public static void main(String[] args) {
Person p1 = new Person();
Person p2 = new Person("Jerry",'M',1990);
Person p3 = new Person("Jane", 'F', 2000);
p1.showMe();
p2.showMe();
p3.showMe();
}
}
答案应该是这个,但我就是不对..呜呜呜.
-unknown-0
Jerry-male-1990
Jane-female-2000