我有一個JLabel PlayerLabel和陣列PlayerName數組,它是intialised以下方式字符串變量突然變得字母的組合和數量
String [] PlayerName;
PlayerName = new String[4];
for (int i=0;i<4;i++)
{
PlayerName[i] = "None1";
}
JLabel [] PlayerLabel;
PlayerLabel = new JLabel[4];
for (int i=0;i<4;i++)
{
String num = Integer.toString(i);
String output = "Player " + num + " : " + PlayerName;
PlayerLabel[i] = new JLabel(output);
PlayerLabel[i].setForeground(Color.white);
}
我希望我的JLabel到文本是
玩家1:None1
相反,我得到
玩家1:java.lang.String中; @ 4e9fd887
的@15150ef8
部分更改數字和字母的不同組合,每次我重新啓動程序。
的PlayerName是好的,當我初始化它
我不知道爲什麼,當它在輸出
什麼是添加的PlayerName變得怪異發生,我該如何解決這個問題?