当前位置: 技术问答>java相关
inner class 语法问题:请进
来源: 互联网 发布时间:2017-04-24
本文导语: class I { class BroterOfI{ BroterOfI(){ System.out.println("construct BrotherOfI"); } } I(){ System.out.println("construct I"); } } public class f9{ public static void main(String[] args){ I i = new I(); I.new BrotherOfI(); ...
class I {
class BroterOfI{
BroterOfI(){
System.out.println("construct BrotherOfI");
}
}
I(){
System.out.println("construct I");
}
}
public class f9{
public static void main(String[] args){
I i = new I();
I.new BrotherOfI();
//该如何写上面这句?谢谢
}
}
class BroterOfI{
BroterOfI(){
System.out.println("construct BrotherOfI");
}
}
I(){
System.out.println("construct I");
}
}
public class f9{
public static void main(String[] args){
I i = new I();
I.new BrotherOfI();
//该如何写上面这句?谢谢
}
}
|
是想创建一个内部类的对象吗?
public class f9{
public static void main(String[] args){
I i = new I();
I.BrotherOfI t = i.new BrotherOfI();
}
}
public class f9{
public static void main(String[] args){
I i = new I();
I.BrotherOfI t = i.new BrotherOfI();
}
}
|
同意楼上
|
同意楼上。建议楼主去看看《Thinking in JAVA》这本书,那里面关于内部类讲的很详细!
|
同意