day02--运算符_算术运算符_字符串连接
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.inmind.operator02;
|
||||||
|
/*
|
||||||
|
运算符_算术运算符_字符串连接
|
||||||
|
|
||||||
|
+ 符号在遇到字符串的时候,表示连接、拼接的含义。
|
||||||
|
|
||||||
|
当数字与字符串进行使用+来进行运算时,进行了拼接操作,拼接成一个更长的字符串
|
||||||
|
*/
|
||||||
|
public class Demo08 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//定义一个字符串
|
||||||
|
String str = "abc";
|
||||||
|
String str1 = "123";
|
||||||
|
System.out.println(str + str1);//abc123
|
||||||
|
|
||||||
|
|
||||||
|
//数字与字符串进行加法运行
|
||||||
|
System.out.println("abc"+123);
|
||||||
|
System.out.println(123+"abc"+123);
|
||||||
|
System.out.println(1+3+"abc");
|
||||||
|
System.out.println(1+3+"abc"+1+3);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user