我写的Java程序中不知道为什么,就是报错
packagefengzhuanglei;publicclassPersonal{//定义类publicStringname;//定义属性publicchargender...
package fengzhuanglei;
public class Personal {//定义类
public String name;//定义属性
public char gender;
public int age;
public double height;
public double weight;
public Personal(String n,char g,int a,double h,double w){//定义构造器
name=n;
gender=g;
age=a;
height=h;
weight=w;//给属性赋值
}
public void speak(String word){
System.out.println(name+"说:"+word);
}
public static void main(String[] args){
Personal person; / /就在这里有警告,然后就运行不了
person=new Personal("张三",'男',18,175.0,65.0);
}
} 展开
public class Personal {//定义类
public String name;//定义属性
public char gender;
public int age;
public double height;
public double weight;
public Personal(String n,char g,int a,double h,double w){//定义构造器
name=n;
gender=g;
age=a;
height=h;
weight=w;//给属性赋值
}
public void speak(String word){
System.out.println(name+"说:"+word);
}
public static void main(String[] args){
Personal person; / /就在这里有警告,然后就运行不了
person=new Personal("张三",'男',18,175.0,65.0);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询