- 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:

推薦閱讀
- Java異步編程實戰
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- Object-Oriented JavaScript(Second Edition)
- 大學計算機基礎(第2版)(微課版)
- Responsive Web Design by Example
- Python High Performance Programming
- 實戰Java高并發程序設計(第2版)
- 零基礎學C++(升級版)
- Photoshop智能手機APP界面設計
- Mastering SciPy
- Python預測分析與機器學習
- Solr權威指南(下卷)
- C語言程序設計實驗指導與習題精解