gpt4 book ai didi

JAVA 错误的变量引用?收到奇怪的输出 - 可能是内存地址?

转载 作者:行者123 更新时间:2023-11-29 05:27:19 24 4
gpt4 key购买 nike

<分区>

public class working {

public static String str = "123zASdcvb/;[";

public static void main(String[] args){
System.out.println("!!!"+new LetterInventory(str));
}

public static class LetterInventory {
public char[] arr;


public LetterInventory(String str){
//Strips our string of all non alphabetic garbage
//and assigns it. This regex removes all non a-z
//without regard for case of alphabet (?!).
this.arr = str.replaceAll("[^a-z]", "").toLowerCase().toCharArray();
Arrays.sort(this.arr); //I want to have it sorted to make my life easier.

System.out.printf("Our freshly sorted LI is : %s\n",this.toString());
}


//Simple enough.
public String toString() {
return this.arr.toString();
}




}
}

输出:

Our freshly sorted LI is : [C@6d69c9a2
!!![C@6d69c9a2

这里出了什么问题?我浏览了我的调试器,我的数组完全按照我的要求进行,它的创建、清理和排序都很好。但是每次我尝试打印我的 char[].toString() 时,它都会出现问题。为什么会这样?

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