class person{
private String name;
public person(String name){
this.name = name ;
}
public String getName(){
return name;
}
// public void setName( String name){
// this.name= name;
// }
}
public class ObjectArray{
public static void main(String args[]){
person per1[] = new person(3);
per1[0] = new person("aa");
per1[1] = new person("asd");
per1[2] = new person("dfff");
// per1[0].setName("张三");
System.out.println(per1[0].getName());
}
}
ObjectArray.java:35: 错误: 不兼容的类型: int无法转换为String
person per1[ ]= new person(3);
^
注: 某些消息已经过简化; 请使用 -Xdiags:verbose 重新编译以获得完整输出
1 个错误
|