我正在尝试在 Java 中连接字符串。为什么这不起作用?
public class StackOverflowTest {
public static void main(String args[]) {
int theNumber = 42;
System.out.println("Your number is " . theNumber . "!");
}
}
最佳答案
您可以使用 +
运算符连接字符串:
System.out.println("Your number is " + theNumber + "!");
theNumber
隐式转换为字符串 "42"
。
关于java - 如何在 Java 中连接两个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3753869/