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 婶婶拜年祝福语大全简短