Java靜態變數塊使用案例

雲驛站發表於2013-11-26

版權宣告:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/qingfeng812/article/details/16974493

package CH181;

/**
 * Description:
 * <br/>Copyright (C), 2008-2010, Yeeku.H.Lee
 * <br/>This program is protected by copyright laws.
 * <br/>Program Name:
 * <br/>Date:
 * @author  Yeeku.H.Lee kongyeeku@163.com
 * @version  1.0
 */
public class Test
{

static
{
//使用靜態初始化塊為b變數指定出初始值
b = 6;
System.out.println(“———-“);
}
//宣告a變數時指定初始值
static int a = 5;
static int b= 9;
static int c;

public static void main(String[] args)
{
System.out.println(Test.b);
}

}


相關文章