当前位置: 技术问答>java相关
一个bean引用另一个bean,怎么办?
来源: 互联网 发布时间:2015-09-08
本文导语: one is:one.java package aaa; public class one{ public one(){} public funb(){} } other is:two.java package aaa; import aaa.*; //can I write by this way? public class two{ aaa x = new one(); //can I write by this way? x.funb(); } | one...
one is:one.java
package aaa;
public class one{
public one(){}
public funb(){}
}
other is:two.java
package aaa;
import aaa.*; //can I write by this way?
public class two{
aaa x = new one(); //can I write by this way?
x.funb();
}
package aaa;
public class one{
public one(){}
public funb(){}
}
other is:two.java
package aaa;
import aaa.*; //can I write by this way?
public class two{
aaa x = new one(); //can I write by this way?
x.funb();
}
|
one is:one.java
package aaa;
public class one{
public one(){}
public funb(){}
}
other is:two.java
package aaa;
import one;
public class two{
aaa x = new one(); //can I write by this way?
x.funb();
}
package aaa;
public class one{
public one(){}
public funb(){}
}
other is:two.java
package aaa;
import one;
public class two{
aaa x = new one(); //can I write by this way?
x.funb();
}
|
同一package中类的引用不需要import
可以直接用
可以直接用
|
aaa x = new one();
error!
error!