- Java Programming for Beginners
- Mark Lassoff
- 113字
- 2021-07-02 15:22:47
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:

推薦閱讀
- Spring Boot 2實戰(zhàn)之旅
- Boost程序庫完全開發(fā)指南:深入C++”準”標準庫(第5版)
- C程序設(shè)計簡明教程(第二版)
- Learning Data Mining with Python
- Mastering Spring MVC 4
- jQuery從入門到精通 (軟件開發(fā)視頻大講堂)
- 精通API架構(gòu):設(shè)計、運維與演進
- 深度強化學(xué)習(xí)算法與實踐:基于PyTorch的實現(xiàn)
- 零基礎(chǔ)學(xué)C語言第2版
- Julia High Performance(Second Edition)
- Functional Python Programming
- Flink入門與實戰(zhàn)
- Spring Boot從入門到實戰(zhàn)
- Splunk Developer's Guide(Second Edition)
- jQuery EasyUI從零開始學(xué)