我一直在搜索java教科书几个小时试图确定我做错了什么.我得到的错误是第13行的"找不到符号",这是代码行:
System.out.println("The three initials are " +
getInitials(Harry, Joseph, Hacker));
Run Code Online (Sandbox Code Playgroud)
说明在代码中注释.我很确定它与我设置的名字有关..但我不确定.
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;
}
}
Run Code Online (Sandbox Code Playgroud)
Sud*_*hul 16
System.out.println("The three initials are "
+ getInitials("Harry", "Joseph", "Hacker")); //Enclosed within double quotes
Run Code Online (Sandbox Code Playgroud)
这就是你传递String文字的方法.
| 归档时间: |
|
| 查看次数: |
373 次 |
| 最近记录: |