<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-9  評論-0  文章-0  trackbacks-0
    代碼如下:
    public class StringTest    
    {   
        
    static final String s1 = "H";   
        
    static final String s2 = "ello";   
        
    static final String s3 = "Hello";   
           
        
    static String ss1 = "H";   
        
    static String ss2 = "ello";   
        
    static String ss3 = "Hello";   
           
        
    static final String s11;   
        
    static final String s22;   
           
        
    static  
        
    {   
            s11 
    = "H";   
            s22 
    = "ello";   
        }
       
           
        
    public static void main(String[] args)   
        
    {   
            
    //1   
            String str1 = "H";   
            String str2 
    = "ello";   
            String str3 
    = "Hello";   
            String str4 
    = str1 + str2;   
            String str5 
    = "H" + "ello";   
               
            System.out.println(str4 
    == str3);   
            System.out.println(str5 
    == str3);   
               
            
    //2   
            String s4 = s1 + s2;   
               
            System.out.println(s4 
    == s3);   
            System.out.println(s4 
    == str3);   
               
            
    //3   
            String ss4 = ss1 + ss2;   
            System.out.println(ss4 
    == s3);   
            System.out.println(ss4 
    == ss3);   
            System.out.println(ss4 
    == str3);   
               
            
    //4   
            String s33 = s11 + s22;   
            System.out.println(s33 
    == s3);   
            System.out.println(s33 
    == ss3);   
            System.out.println(s33 
    == str3);   
        }
       
    }
      

    輸出結果:
     1false  
     2true  
     3true  
     4true  
     5false  
     6false  
     7false  
     8false  
     9false  
    10false 

    static final String的定義使其成為編譯時常量,所以String s4 = s1 + s2;  實際是String s4 = “H” + “ello”,也就是“Hello”,3,4輸出為true。而s11,s22雖然是static final的,但是是在static塊中初始化,編譯時不會成為常量。
    posted on 2009-11-14 13:28 AndyFish 閱讀(95) 評論(0)  編輯  收藏 所屬分類: 基礎知識

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 在线观看亚洲一区二区| 国产男女猛烈无遮挡免费视频网站| 国产免费一区二区三区免费视频| 精品国产呦系列在线观看免费| 日本中文一区二区三区亚洲 | 免费无码婬片aaa直播表情| 国产精品免费久久久久电影网| 天天影视色香欲综合免费| 成年人免费网站在线观看| 久久99亚洲综合精品首页| 亚洲日韩中文字幕天堂不卡| 亚洲爆乳精品无码一区二区| 一区二区三区无码视频免费福利| 啦啦啦中文在线观看电视剧免费版 | 好爽…又高潮了毛片免费看| 亚洲人成人网站色www| 国产成人亚洲综合一区 | 免费福利在线视频| 国产国产人免费视频成69大陆| 国产精品亚洲lv粉色| 亚洲一区二区三区免费观看 | 亚洲av片一区二区三区| 中国videos性高清免费| 国内大片在线免费看| 视频一区二区三区免费观看| 免费涩涩在线视频网| 91午夜精品亚洲一区二区三区| 国产黄在线观看免费观看不卡| 久久亚洲一区二区| h视频免费高清在线观看| 久久久久亚洲AV无码网站| 久久久WWW成人免费精品| 亚洲高清在线视频| 最新亚洲人成无码网站| JLZZJLZZ亚洲乱熟无码| 337p日本欧洲亚洲大胆人人| 国产综合亚洲专区在线| baoyu116.永久免费视频| 亚洲伊人久久大香线蕉综合图片| 色欲国产麻豆一精品一AV一免费| 亚洲人成伊人成综合网久久久|