我一直在搜索 Java 教科书好几个小时,试图确定我做错了什么。我回来的错误是第 13 行的“找不到符号”,这是代码行:
System.out.println("The three initials are " +
getInitials(Harry, Joseph, Hacker));
指令在代码中注释。我很确定这与我设置的名称有关。但我不确定。
public class InitialsTest {
/**
Gets the initials of this name
@params first, middle, and last names
@return a string consisting of the first character of the first, middle,
and last name
*/
public static void main(String[] args) {
System.out.println("The three initials are " +
getInitials(Harry, Joseph, Hacker));
}
public static String getInitials(String one, String two, String three) {
String initials = one.substring(0,1) + two.substring(0,1) + three.substring(0,1);
return initials;
}
}