我需要遍历a BucketMap并获取所有内容,keys但是如何在不buckets[i].next.next.next.key尝试手动操作的情况下进行操作,如我在此处尝试的那样:
public String[] getAllKeys() {
int j = 0; //index of string array "allkeys"
String allkeys[] = new String[8];
for(int i = 0; i < buckets.length; i++) { //iterates through the bucketmap
if(buckets[i] != null) { //checks wether bucket has a key and value
allkeys[j] = buckets[i].key; //adds key to allkeys
j++; // counts up the allkeys index after adding key
if(buckets[i].next != null) { //checks wether next has a key and value
allkeys[j] …Run Code Online (Sandbox Code Playgroud)