gpt4 book ai didi

java - 将整数包含到字符串中

转载 作者:行者123 更新时间:2023-12-01 10:19:40 24 4
gpt4 key购买 nike

我想问一些简单的问题。我创建了一个有名称的类。我想创建几个这样的类,但它们的数量并不确切。每个类都有一个唯一的名称

我想要什么:

例如我们有 3 个类,那么它们的名称应该是:

#1 类

第 2 类

第 3 类。

我在想这样的事情:

for(int i = 0 ; i < numberofclasses ; i++ )
{
C[i] = new Class("Class # **(i+1)** " ); (where i+1 , is the number of class)
}

附注:接受任何更好标题的建议

最佳答案

这是我的首选方式。我不喜欢 + 因为它也可以用于数学运算。

// Call String.format with three integer codes.
String result = String.format("One: %1$d Two: %2$d Three: %3$d",10, 20, 30);
System.out.println(result);

关于java - 将整数包含到字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35683050/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com