2015-12-08 40 views
0

得到以下錯誤:誤差探測法:找不到符號

error: cannot find symbol so = Soundex.parse(s, true);

public static List<String> getSimilar(String s) 
{ 
    List<String> simWords = new LinkedList<>(); 

    // Find uppercase and lowercase Soundex ID for letters 
    String so; 
    if (Character.isLetter(s.charAt(0))) { 
     so = Soundex.parse(s, true); 
     if (dictionary.containsKey(so)) simWords.addAll(dictionary.get(so)); 
     so = Soundex.parse(s, false); 
     if (dictionary.containsKey(so)) simWords.addAll(dictionary.get(so)); 
    } 
    else { 
     so = Soundex.parse(s); 
     if (dictionary.containsKey(so)) simWords.addAll(dictionary.get(so)); 
    } 

    return simWords; 
} 

我有在同一文件夾中文件和內Soundex.java,該班被命名爲Soundex和方法如下:

static String parse(String s, boolean uppercase) { 
    Soundex sx = new Soundex(s); 
    if (uppercase) { 
     sx.code[0] = Character.toUpperCase(sx.code[0]); 
    } else { 
     sx.code[0] = Character.toLowerCase(sx.code[0]); 
    } 
    return new String(sx.code); 
} 
+0

它看起來像編譯器抱怨Soundex.parse(s,true);但是,我不是積極的,這是一個編譯器信息或你的解釋。不過,我注意到只有一行參數調用了parse()。 –

回答

0

我可以看到你在呼喚兩種方法,

so = Soundex.parse(s); 
so = Soundex.parse(s, true); 

但根據方法確定指標,只有

static String parse(String s, boolean uppercase) 

mthod簽名存在。請檢查是否存在一個論證的第一種方法。

+0

是的,有一種方法接受一個參數。 (String s){ return new String(new Soundex(s).code); } – Tii