这有效:
int depth = 5;String str= "Hello"+ String.format("%"+depth+"s"," ") + "world" + "n";System.out.println(str);在中间有空格的同时打印5。
你好,世界。
请检查您的代码,并确保
depth已为其分配有效值
int。(很可能是的无效值
depth)是问题所在。

这有效:
int depth = 5;String str= "Hello"+ String.format("%"+depth+"s"," ") + "world" + "n";System.out.println(str);在中间有空格的同时打印5。
你好,世界。
请检查您的代码,并确保
depth已为其分配有效值
int。(很可能是的无效值
depth)是问题所在。