官术网_书友最值得收藏!

The concatenation operator

Another thing strings can do, which most Java classes cannot, is make use of the addition sign (+) operator. If we declare three strings (say, s1, s2, and s3), we can set the value of our third string to be one string plus another string. We can even add a string literal into the mix. Then, we print s3:

package stringsinjava; 
 
public class StringsInJava { 
    
    public static void main(String[] args) { 
        char c = 'c'; 
        String s1 = "stringone"; 
        String s2 = "stringtwo"; 
        String s3 = s1+s2+"LIT"; 
        System.out.println(s3); 
    } 
} 

When we run this program, we'll see these three strings added together in much the manner that we would expect:

主站蜘蛛池模板: 静海县| 成都市| 枣庄市| 华蓥市| 房山区| 洪洞县| 买车| 化州市| 兴宁市| 安远县| 肥乡县| 平利县| 普陀区| 赫章县| 鹰潭市| 康乐县| 平阴县| 高密市| 明水县| 辉南县| 南投市| 中牟县| 青河县| 会昌县| 正安县| 阿城市| 沿河| 诏安县| 应城市| 蓬安县| 杭锦后旗| 中牟县| 菏泽市| 高陵县| 应用必备| 衢州市| 毕节市| 彝良县| 杭锦后旗| 紫阳县| 九台市|