2010-10-07 60 views
2

我在我的代碼中得到「字符串不能解析爲類型」錯誤。字符串不能解析爲一個類型

public class Main { 


public static void main(String[] args) { 
    // TODO Auto-generated method stub 
    FormLetter template; 
    template = new FormLetter(); 
    template.print(); 
    template.composeFormLetter(Sean, Colbert, God); 
    template.print(); 

} 

} 

class FormLetter 
{ 
    public void print(){ 
    System.out.println(to + candidate + from); 

    } 

    public void composeFormLetter(string t, string c, string f){ 

    to = t; 
    candidate = c; 
    from = f; 
    } 
    private string to; 
    private string candidate; 
    private string from; 

    } 
+2

爲了將來的參考,請務必在您的問題中發佈整個編譯器錯誤消息(如果存在),以便更容易查明錯誤。 – 2010-10-07 00:16:39

回答

7

String在Java中是大寫。你不能使用小寫字母string。 (這是C#)

旁邊的問題:
下面的編譯如何?

template.composeFormLetter(Sean, Colbert, God); 
+0

好吧,我糾正了字符串問題。 template.composeFormLetter(肖恩,科爾伯特,上帝);錯誤離開:多個標記在該行 - 上帝解決不了 - 科爾伯特不能 解決 - 肖恩不能 解決 – chief 2010-10-07 00:27:22

+1

@chief - 字符串字面應該有他們周圍的雙引號。 (側面的回答 - 這不是......) – 2010-10-07 00:29:33

+0

@chief,''上帝'',''肖恩'',''科爾伯特''你需要把'Strings'放在引號內。 – jjnguy 2010-10-07 00:31:32

相關問題