<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)  編輯  收藏 所屬分類: 基礎知識

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲特级aaaaaa毛片| 中文字幕亚洲日本岛国片| 亚洲欧洲精品国产区| 亚欧在线精品免费观看一区| 亚洲资源在线观看| 亚洲高清免费在线观看| 亚洲国产成人综合| 在线播放高清国语自产拍免费 | 色噜噜亚洲精品中文字幕| 成在线人直播免费视频| 亚洲人成电影在线播放| 国产精品成人免费观看| 亚洲AV无码精品色午夜在线观看| 国产好大好硬好爽免费不卡| 久久国产亚洲高清观看| 狼群影院在线观看免费观看直播| 亚洲人和日本人jizz| 国产福利免费在线观看| 2022国内精品免费福利视频| 亚洲AV无码第一区二区三区| 一级毛片免费毛片一级毛片免费| 亚洲欧洲日本国产| 免费观看大片毛片| WWW国产成人免费观看视频| 亚洲今日精彩视频| 99re热免费精品视频观看| 麻豆安全免费网址入口| 亚洲日韩一页精品发布| 国产精品视频免费| 免费一级特黄特色大片| 久久精品国产亚洲av成人| 18禁无遮挡无码网站免费| 一区二区免费电影| 亚洲婷婷天堂在线综合| 亚洲AⅤ永久无码精品AA| 香蕉成人免费看片视频app下载| 亚洲一区欧洲一区| 亚洲熟妇无码乱子AV电影| 久久久久久国产精品免费免费| 久青草国产免费观看| 亚洲一区精彩视频|