点击运行
public class Main { public static void main(String[] args) { // 这里的代码不能使用 x { // 这是一个块 // 这里的代码不能使用 x int x = 100; // 这里的代码可以使用 x System.out.println(x); } // 这里是块之外的代码,不能使用 x } }
运行结果 :
正在执行...