Jump to content

Java Help

Go to solution Solved by Nuluvius,

Line 21:

result += "Home Address:\n" = homeAddress + "\n";

Should be:

result += "Home Address:\n" + homeAddress + "\n";

Hi, for some reason I am getting an error that says "The left-hand side of an assignment must be a variable" on line 21. Am I being blind on and not missing some obvious mistake? Thanks!

package four.eight;public class Student{    private String firstName, lastName;  private Address homeAddress, schoolAddress;    public Student (String first, String last, Address home, Address school)  {    firstName = first;    lastName = last;    homeAddress = home;    schoolAddress = school;  }    public String toString()  {    String result;    result = firstName + " " + lastName + "\n";    result += "Home Address:\n" = homeAddress + "\n";    result += "School Address:\n" + schoolAddress;    return result;  }}
Link to comment
https://linustechtips.com/topic/319945-java-help/
Share on other sites

Link to post
Share on other sites

ah. Stupid typo. Thank you!

 

No problem, it happens to us all. Especially after staring at the same code for hours on end. I've been down that particular rabbit hole many times :)

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/319945-java-help/#findComment-4348889
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×