Przez wiele godzin czyściłem podręcznik Java, próbując ustalić, co robię źle. Błąd Dostaję powrotem „nie można odnaleźć symbolu” na linii 13, który jest linia z kodem:Java Początkujący: Nie można znaleźć symbolu
System.out.println("The three initials are " +
getInitials(Harry, Joseph, Hacker));
Instrukcje są skomentował w kodzie. Jestem prawie pewien, że ma to związek z nazwami, które ustawiłem. Ale nie jestem pewien.
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;
}
}
Czy funkcja charAt nie powinna używać() zamiast []? Podobnie jak one.charAt (0) + two.charAt (0) + three.charAt (0) –
tak, przepraszam, moje złe :) – Anusha