I've been scouring the java textbook for hours trying to determine what I'm doing wrong. The error I'm getting back is "Cannot find symbol" on line 13, which is the line with the code:
System.out.println("The three initials are " +
getInitials(Harry, Joseph, Hacker));
The instructions are commented in the code. I'm pretty sure it has to do with the names I've set up.. But I'm not sure.
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;
}
}
System.out.println("The three initials are "
+ getInitials("Harry", "Joseph", "Hacker")); //Enclosed within double quotes
This is how you pass String
literals.
System.out.println("The three initials are " +
getInitials("Harry", "Joseph", "Hacker"));
just use the double quotes . if you would have declared them as variables in your code then double quotes are not needed ,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With