Java 无法将字符串解析为类型
我的代码中出现“字符串无法解析为类型”错误Java 无法将字符串解析为类型,java,Java,我的代码中出现“字符串无法解析为类型”错误 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); t
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;
}
字符串
在Java中大写。不能使用小写的字符串
。(那是C#)
附带问题:下面的代码是如何编译的
template.composeFormLetter(Sean, Colbert, God);
为便于将来参考,请确保在问题(如果存在)中发布整个编译器错误消息,以便更容易地查明错误。好的,我已更正了字符串问题。模板.composeFormLetter(肖恩、科尔伯特、上帝);正在留下一个错误:这一行有多个标记-上帝无法解析-科尔伯特无法解析-肖恩无法解析resolved@chief-字符串文字应该有双引号围绕。(旁白-它不是…@chief,
“God”
,“Sean”
,“Colbert”
你需要把字符串
放在引号内。好的,在控制台中它返回:nullnull,然后是God Colbert Sean。@chief,这就是它应该做的吗?