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 教师闺蜜祝福语简短