我想问一些简单的问题。我创建了一个有名称的类。 我想创建几个这样的类,但它们的数量并不确切。每个类都有一个唯一的名称
我想要什么:
例如我们有 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/