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

推薦閱讀
- Extending Jenkins
- C#高級編程(第10版) C# 6 & .NET Core 1.0 (.NET開發經典名著)
- Hyper-V 2016 Best Practices
- Power Up Your PowToon Studio Project
- Java程序設計:原理與范例
- ArcGIS By Example
- Gradle for Android
- BIM概論及Revit精講
- PySpark Cookbook
- Scala for Machine Learning(Second Edition)
- 智能搜索和推薦系統:原理、算法與應用
- Python入門很輕松(微課超值版)
- Building Dynamics CRM 2015 Dashboards with Power BI
- Python+Office:輕松實現Python辦公自動化
- Web前端開發技術:HTML、CSS、JavaScript