不能通过吧,大哥
我用JCreator3.0试的
我用JCreator3.0试的
解决方案 »
- hibernate save
- Cannot get a connection, pool exhausted
- format("InsertImage", sPhoto); 插入图片语句,如何修改成在子页中插入?
- myeclipse8.5无法正常打开struts.xml导入文件
- eclipse报表项目,需要使用水晶报表,急求示例或完整教程!(无使用报表工具经验)
- 哪位高人能不能详细谈一下jsp里操作数据库的问题?
- 为什么我的gmail今天死活登陆不上去了啊 ??大家的怎么样,寻求原因?????
- 下载时,文件输出流出错,急啊!
- 通过使用<c:froEach>标签,如何输入一个9*9表格呢?
- 国家污染源卫星实时监控系统,希望各位技术支持!
- 用JAVASCRIPT如何判断用户在提交表单文本框中输入的前两个字符是“B0”
- 一个郁闷吐血的问题——如何去掉保存对话框。
int x=12;
{
x=96;
System.out.print(x);
}
System.out.println(x);
}应该这样测试啊
我刚刚不信,所以我用eclipse试了一下,编译无法通过……
提示信息为“局部变量 x 重复”。
import java.applet.Applet;
public class Scoping extends Applet {
int x=1; //此处的全局x可以被下面出现的x给屏蔽掉。
public void paint(Graphics g) {
g.drawString("See command line for output", 25, 25 );
int x=5;
System.out.println("local x in paint is "+x);
a();
b();
a();
b();
System.out.println("\nlocal x in paint is "+x);
c();
}
void a() {
int x=25;
System.out.println("\nlocal x in a is "+x+" after entering a");
++x;
System.out.println("local x in a is "+this.x+" before exiting a");
}
void b() {
System.out.println("\ninstance variable x is "+x+" on entering b");
this.x*=10;//原来是 x*=10;
System.out.println("\ninstance variable x is "+this.x+" on entering b");
}
void c() {
System.out.println("最后输出全局x:"+x);
}
}
正如上面的代码所示,全局的int x=1; 能被paint()中的int x=5;给屏蔽掉,是不是当int x=1;是全局变量时就能给屏蔽掉?
{
int x=12;
{
int x=96;
}
}
int x = 16;
{
int x = 24;
}
}楼主是这样写的? {
int x = 24;
}
这是一个block,相当于一个方法,而不是声明,第二个X是局部变量
如果写在方法里这样是肯定通不过的