由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 百思不解 why the program fails?
相关主题
关于Jbuilder7???JAVA APPLICATION PATH 一问
Test your PC speed两个很基本的JAVA问题
折腾了一天,实在是绝望了,请教请教jdbc连接数据库出现的问题
Re: how to initialize corba object orb in servletDoes anyone know where I can find this?
说说clone咋违反了类继承的原则来的?问个Thread 的问题,java certificate里的
java Stringquestion on single thread & multithread
Re: unix环境下如何在java程序中执行命令行?Urgent help! Java relative file path
Re: [转载] 如何看某个端口是否被占用?(use UNIX command or ..)is there anyway that i can return...
相关话题的讨论汇总
话题: 百思不解话题: int话题: string话题: fail话题: main
进入Java版参与讨论
1 (共1页)
t*****z
发帖数: 812
1
为什么第一个fail,第二个通过?不就调了一下循序么,百思不解
**fail
public static void main ( String args[] ) {
int x = 50;
System.out.println("x= "+x);
{
int x= 30; //compilation fail: x is already defined in main
System.out.println("x= " + x);
}
}
**pass
public static void main ( String args[] ) {
{
int x= 30;
System.out.println("x= " + x);
}
int x = 50;
System.out.println("x= "+x);
}
m*****u
发帖数: 1342
2
I suspect in the second case, the x defined earlier was out of scope when
the second x is being declared, which is not true for the first case.

【在 t*****z 的大作中提到】
: 为什么第一个fail,第二个通过?不就调了一下循序么,百思不解
: **fail
: public static void main ( String args[] ) {
: int x = 50;
: System.out.println("x= "+x);
: {
: int x= 30; //compilation fail: x is already defined in main
: System.out.println("x= " + x);
: }
: }

r*****l
发帖数: 2859
3
Your understanding is right.

【在 m*****u 的大作中提到】
: I suspect in the second case, the x defined earlier was out of scope when
: the second x is being declared, which is not true for the first case.

1 (共1页)
进入Java版参与讨论
相关主题
is there anyway that i can return...说说clone咋违反了类继承的原则来的?
新手求助,急急急!!!java String
help "java.lang.NoSuchMethodError"Re: unix环境下如何在java程序中执行命令行?
Java menu accelerator not workingRe: [转载] 如何看某个端口是否被占用?(use UNIX command or ..)
关于Jbuilder7???JAVA APPLICATION PATH 一问
Test your PC speed两个很基本的JAVA问题
折腾了一天,实在是绝望了,请教请教jdbc连接数据库出现的问题
Re: how to initialize corba object orb in servletDoes anyone know where I can find this?
相关话题的讨论汇总
话题: 百思不解话题: int话题: string话题: fail话题: main