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

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:

主站蜘蛛池模板: 信丰县| 星子县| 正定县| 开化县| 开阳县| 武夷山市| 保定市| 潮州市| 嘉善县| 修文县| 金昌市| 开原市| 雷波县| 苏尼特右旗| 城步| 都昌县| 嘉禾县| 尼勒克县| 南平市| 岳池县| 酒泉市| 陵水| 富宁县| 富裕县| 沂南县| 双牌县| 明光市| 淮安市| 德安县| 南宫市| 祁连县| 安宁市| 雷州市| 松滋市| 淮南市| 无极县| 遂溪县| 开阳县| 新泰市| 乾安县| SHOW|