编译java报错,提示找不到符号,符号是构造函数

黎前点星 2016-11-19 09:20:16
class Xinxi
{
String name;
int age;
public static int count = 0;

public void Xinxi(String name,int age){
count++;
this.name = name;
this.age = age;
System.out.println("产生了" + count + "个对象!");
}

public void info(){
System.out.println("姓名"+this.name+",年龄"+this.age+",生成对象"+count);
}



}



public class Demo1
{
public static void main(String args[]){
Xinxi x1 = new Xinxi("zhangsan",1);
Xinxi x2 = new Xinxi("lisi",2);
Xinxi x3 = new Xinxi("wanger",3);

x1.info();
x2.info();
x3.info();

}
}
...全文
177 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinat_36760865 2016-11-19
  • 打赏
  • 举报
回复
你没有构造函数,构造方法没有void修饰,有void它就是一个普通方法

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧