-1
我在製作一個程序來創建霍夫曼樹。當我到達第31行(node [i] = setFreq(freq);)時,我的編譯器返回一個錯誤「找不到符號」,符號爲「method setFreq(int)」,位置爲「class Huffman」。據我可以告訴節點[我]是正確初始化爲NodeType,但不回到類提到的行。下面是我的代碼的一部分,應該是所有必要的(道歉,如果它不是)。輸入表將是字母頻率線後線,即: A-3 B-32 C-23 等 感謝您的任何幫助提前。在類之間找不到符號
import java.io.*;
import java.util.*;
public class Huffman{
final static int MAXBITS = 138;
final static int MAXSYMBS = 138;
final static int MAXNODES = 255;
public static void Huffman(){
CodeType cd = new CodeType();
CodeType code[] = new CodeType[MAXSYMBS];
NodeType node[] = new NodeType[MAXNODES];
int i, k, p, o, q, root, freq;
DynamicList rootNodes = new DynamicList();
char symb;
char alph[] = new char[MAXSYMBS];
for (i=0; i<MAXSYMBS; i++){
alph[i] = ' ';
}
try (BufferedReader br = new BufferedReader(new FileReader("HuffmanTable.txt"))){
String line;
i=0;
while ((line = br.readLine()) != null){
String[] parts = line.split("-");
node[i] = new NodeType();
String trick = parts[0];
symb = trick.charAt(0);
freq = Integer.parseInt(parts[1]);
node[i] = setFreq(freq);
rootNodes.pqInsert(new SmallNode(i, freq));
alph[i] = symb;
i++;
}
}
}
而且節點類型類
public class NodeType{
private int freq;
private int father;
private boolean isLeft;
public NodeType(){}
public void isLeft(boolean fact){
isLeft = fact;
}
public boolean isLeft(){
return isLeft;
}
public void setFreq(int fr){
freq = fr;
}
public int getFreq(){
return freq;
}
public void setFather(int fath){
father = fath;
}
public int getFather(){
return father;
}
}