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

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:

主站蜘蛛池模板: 巴里| 兴海县| 洞口县| 峨眉山市| 无锡市| 兰考县| 西安市| 都江堰市| 封丘县| 固原市| 分宜县| 巴林右旗| 河南省| 宝鸡市| 靖西县| 当涂县| 滨州市| 萨嘎县| 秀山| 科技| 永昌县| 扶沟县| 工布江达县| 泗水县| 双桥区| 水城县| 区。| 中牟县| 土默特右旗| 兴宁市| 凤台县| 聂拉木县| 响水县| 常州市| 河南省| 同仁县| 台安县| 马鞍山市| 朔州市| 乐安县| 武冈市|