//测试全局变量及局部变量的输出结果的异同

package com.chongrui.test;
//测试全局变量及局部变量的输出结果的异同,成员变量如果与局部变量相同,暂时是失效的,如果要调用成员变量需要:类名+变量名
public class Gess {
static int times = 1;   //定义成员变量
public static void main (String[] args){

int times = 4;        //定义局部变量


System.out.println("输出全局变量"+Gess.times);
System.out.println("输出局部变量"+times);


}


}

原文地址:https://www.cnblogs.com/tantanba/p/6217886.html