我正在尝试使用该方法将 a 表示int
为 a ,但我不确定如何达到预期的结果。String
toString()
我所拥有的是:
public class Item {
int item;
public Item () {
item = 3;
}
public Item (int item) {
this.item = item;
}
public void toString() {
String[] anArray = new string[10];
anArray[0] = "item 0";
anArray[1] = "item1";
anArray[2] = "item2";
anArray[3] = "item3";
anArray[4] = "item4";
anArray[5] = "item5";
anArray[6] = "item6";
anArray[7] = "item7";
anArray[8] = "item8";
anArray[9] = "item9";
if (item >= 0 && item < 10)
System.out.println("Item " + item + " = " + anArray[item]);
else
System.out.println("Item does not exist.");
}
}
如何在数组中将 a 表示int
为 a ?String