【发布时间】:2019-08-16 11:54:44
【问题描述】:
我读过其他帖子,而不是只写System.out.println(finalPressedKey);
你应该写System.out.println(Arrays.toString((finalPressedKey));,否则它只会返回保存字符串的位置(据我所知)。
public static String PressedKey[] = new String[2000];
public static String[][] finalPressedKey = {{ "", "", "", "", "", "", "", "", "", "", "", "" }}; // 12
public static String FPK3;
public static void upcounter(KeyEvent e) {
for (int x = 0; x < PressedKey.length; x++) {
if (PressedKey[x] != null && PressedKey[x + counter] != null) {
//FPK counter is supposed to be a line, and counter is where the words are supposed to be saved
finalPressedKey[FPKcounter][counter] =
finalPressedKey[FPKcounter] + PressedKey[x + counter];
System.out.println(Arrays.toString(finalPressedKey));
}
}
每当我按下一个按钮时,它都应该保存在我的 PressedKey 数组中,并且 finalPressedKey 应该包含自己,并且 PressedKey (同样,应该只打印数组的最后一个元素),但是相反,它只打印[[Ljava.lang.String;@76f42c4b]
我也尝试过使用Arrays.deepToString();,但它给了我与Arrays.toString();相同的输出
感谢您的帮助!
【问题讨论】:
-
如果你想如果你使用
Arrays.deepToString()它会工作。您如何发布您的尝试? -
否则它只会返回保存字符串的位置--这是打印的对象内部哈希码,与“位置”没有任何关系
标签: java string eclipse multidimensional-array