1 Star 12 Fork 12

RichardGong / PlayWithCompiler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
BlockScope.play 335 Bytes
一键复制 编辑 原始数据 按行查看 历史
/**
测试对块作用域的支持。
*/
//全局变量
int i = 0;
println(i); //输出:0
{
//这里引用的是全局变量
i = 2;
println(i); //输出:2
//允许在块里新创建一个同名的变量
int i = 3;
println(i); //输出:3
}
//重新看看全局变量的值
println(i); //输出:2
Java
1
https://gitee.com/richard-gong/PlayWithCompiler.git
git@gitee.com:richard-gong/PlayWithCompiler.git
richard-gong
PlayWithCompiler
PlayWithCompiler
master

搜索帮助