我希望程序打印 A car with number of wheels has been created.
Numbers of wheels = <wheels variable value>
.
我尝试使用占位符,如C#
{0}或{1}:System.out.println("A car with {0} wheels created", wheels);
最佳答案
使用 +
作为连接字符串的方式,如下所示:
System.out.println(“已经创建了一辆带有“+wheels+”wheels的汽车。”)
其中wheels是你的变量
关于java - 如何在文本中打印变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57332138/