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 父母生孩子祝福语简短