【JAVA小结】类的属性组的使用

    public class UsingAttribute {
    static String strA = "string-a";
    static String strB;
    static String strC = "string-c";
    static String strD;
    
    static
    {
    	printStatic("before static");
    	strB = "sring-b";
    	printStatic("after static");
    }

    public static void printStatic(String title)
    {
    	System.out.println("------"+title+"-----");
    	System.out.println("strA=\""+strA+"\"");
        System.out.println("strB=\""+strB+"\"");
    }
public static void main(String[] args) {
		// TODO Auto-generated method stub
           
           System.out.println();
           System.out.println("----创建 UsingAttribute 对象 ---");
           System.out.println();
           new UsingAttribute();

	}
    
    public UsingAttribute()
    {
    	print("before constructor");
    	strD="string-d";
    	print("after constructor");
    }

    public static void print(String title)
    {
    	System.out.println("------"+title+"-----");
    	System.out.println("strA=\""+strA+"\"");
        System.out.println("strB=\""+strB+"\"");
        System.out.println("strC=\""+strC+"\"");
        System.out.println("strD=\""+strD+"\"");
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值