//SetVariable.java public class SetVariable {
//全局变量
static double pi = 3.141592654;//数学常量 static short s1; static int i1; static long l1; static char ch1; static float f1; static double d1; static boolean b1;
public static void main(String args[]) {//局部变量 short s2 = 35; int i2 = -32; long l2 = 34555L; char ch2 = 'A'; float f2 = 897.89F; double d2 = 34.345; boolean b2 = false; //输出常量
System.out.println(\数学常量pi = \//输出局部变量
System.out.println(\局部变量******\System.out.println(\短整型变量s2 = \System.out.println(\整形变量i2 = \System.out.println(\长整形变量l2 = \System.out.println(\字符变量ch2 = \System.out.println(\浮点数变量f2 = \System.out.println(\双精度型变量d2 = \System.out.println(\布尔型变量b2 = \//调用方法修改全局变量的值 change();
//输出局部变量的值
System.out.println(\局部变量******\System.out.println(\短整型变量s2 = \System.out.println(\整形变量i2 = \System.out.println(\长整形变量l2 = \System.out.println(\字符变量ch2 = \System.out.println(\浮点数变量f2 = \System.out.println(\双精度型变量d2 = \System.out.println(\布尔型变量b2 = \}
//修改全局变量的值 public static void change()
{ s1 = 125; i1 = 88; l1 = 987654321L; ch1 = 'B'; f1 = 3.2590F; d1 = -1.04E-5; b1 = true; } }

