public class temp
{
public static void main(String args[])
{
class A{}
System.out.println("test");
} public Class X
{
}
}1.这个程序为何出错??
2.为什么可以在main方法内定义类?
3.这样做有什么不好的地方?
{
public static void main(String args[])
{
class A{}
System.out.println("test");
} public Class X
{
}
}1.这个程序为何出错??
2.为什么可以在main方法内定义类?
3.这样做有什么不好的地方?
楼主【sure2003】截止到2008-07-17 13:34:33的历史汇总数据(不包括此帖):
发帖的总数量:246 发帖的总分数:10423 每贴平均分数:42
回帖的总数量:210 得分贴总数量:6 回帖的得分率:2%
结贴的总数量:244 结贴的总分数:10333
无满意结贴数:2 无满意结贴分:50
未结的帖子数:2 未结的总分数:90
结贴的百分比:99.19 % 结分的百分比:99.14 %
无满意结贴率:0.82 % 无满意结分率:0.48 %
值得尊敬
些在main方法的内难于理解和阅读,
class A{
private int s = 111;
public class B {
private int s = 222;
public void mb(int s) {
System.out.println(s); // 局部变量s
System.out.println(this.s); // 内部类对象的属性s
System.out.println(A.this.s); // 外层类对象属性s
}
}
}public class TestInner3{
public static void main(String args[]){
A a = new A();
A.B b = a.new B();
b.mb(333);
}
}