private 成员变量 局部变量

package myclass.struct;							// 定义类包

public class Frist {							// 声明类
	private static String s1 = "让我看看,";		// 成员变量

	public static void main(String[] args) {	// 主方法
		String s2 = "主类的结构。";				// 局部变量
		System.out.print(s1);					// 输出变量s1
		System.out.println(s2);					// 输出变量s2
	}
}

public class Val {										//新建类
	static String words = "全局变量";					//定义全局变量words
	public static void main(String[] args) {			//主方法
		String words = "局部变量";						//定义局部变量words
		System.out.println("words变量现在是:" + words); //将words的值输出
	}
}


原文地址:https://www.cnblogs.com/aikongmeng/p/3697432.html