在Java中,可以使用加號(+)來連接字符串和數字。例如:
```java
int num = 10;
String str = "The number is " + num;
System.out.println(str);
```
這將輸出:
```
The number is 10
```
如果要將數字轉換為字符串再拼接,可以使用`String.valueOf()`方法或者`Integer.toString()`方法。例如:
```java
int num = 10;
String str = "The number is " + String.valueOf(num);
System.out.println(str);
```
或者:
```java
int num = 10;
String str = "The number is " + Integer.toString(num);
System.out.println(str);
```