Java程序来连接整数和字符串
要将整数与字符串值连接在一起,需要使用+运算符。
假设以下是字符串。
String str = "Demo Text";
现在,我们将整数值与上述字符串连接在一起。
String res = str + 1 + 2 + 3 + 4 + 5;
示例
public class Demo {
public static void main(String[] args) {
String str = "Demo Text";
System.out.println("String = "+str);
String res = 99 + 199 + 299 + 399 + str;
System.out.println(res);
}
}输出结果
String = Demo Text 996Demo Text
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短