程序运行错误是什么原因???
以下这段代码在运行时提示出错是什么原因?请高手指点.谢谢!=========================================================================================
JavaProcedure.java:3: 无法从静态上下文中引用非静态 变量 this
Husband h=new Husband("11111","张三","1999-10-11",null);
^
JavaProcedure.java:4: 无法从静态上下文中引用非静态 变量 this
Wife w = new Wife("222222","李四","1998-11-12",null);
^
JavaProcedure.java:25: 找不到符号
符号: 变量 Wife
位置: 类 JavaProcedure.Husband
Wife=w;
^
3 错误
=========================================================================================
public class JavaProcedure{
public static void main(String[] args) {
Husband h=new Husband("11111","张三","1999-10-11",null);
Wife w = new Wife("222222","李四","1998-11-12",null);
h.wife=w;
w.husband=h;
System.out.println(h.name+"的妻子的名字叫"+h.wife.name);
System.out.println(w.name+"丈夫的名字叫"+w.husband.name);
}
class Husband{
String idcard;
String name;
String birth;
Wife wife;
public Husband(){
}
public Husband(String s1,String s2,String s3,Wife w){
idcard = s1;
name =s2;
birth =s3;
k
}
}
class Wife{
String idcard;
String name;
String birth;
Husband husband;
public Wife(){
}
public Wife(String s1,String s2,String s3,Husband h){
idcard = s1;
name =s2;
birth =s3;
husband =h;
}
}
}