public class test1 {
private static String code;
static Boolean isrun;
public test1() {
// TODO Auto-generated constructor stub
}
public String GetCode() {
if (isrun) {
return getCodeTEST3();
} else {
return null;
}
}
public void test2(String code, Boolean isrun ){
this.setCodeTEST3(code,isrun);
} public static void setCodeTEST3(String code, Boolean isrun) {
test1.code = code;
test1.isrun = isrun;
} private static String getCodeTEST3() {
return code;
}
private static Boolean getIsRunTEST3(){
return isrun;
}
}
private static String code;
static Boolean isrun;
public test1() {
// TODO Auto-generated constructor stub
}
public String GetCode() {
if (isrun) {
return getCodeTEST3();
} else {
return null;
}
}
public void test2(String code, Boolean isrun ){
this.setCodeTEST3(code,isrun);
} public static void setCodeTEST3(String code, Boolean isrun) {
test1.code = code;
test1.isrun = isrun;
} private static String getCodeTEST3() {
return code;
}
private static Boolean getIsRunTEST3(){
return isrun;
}
}
就好了
static Boolean isrun;
public test1() {
// TODO Auto-generated constructor stub
}
public String GetCode() {
if (isrun) {
return code;
} else {
return null;
}
}}
-------------test2---------------------public class test2 { public test2()
{
test1.code="yzsunlight";
test1.isrun=true;
}
}
-------------test3---------------------public class test3 {
public static void main(String[] args) {
test2 t=new test2();
System.out.println(test1.code);
}
}
在Test2中调用上边的两个方法给Test1赋值,
在Test3中写MAIN()方法,调用Test2的方法就行了。