0

error: cannot find symbol this.owner = new owner(ownername, telephonenumber);

public class Car extends Vehicle{
    private String body;
    private String type;
    private int ccRating;
    protected static Owner owner;

    public Car(String body, String type, int ccRating)
    {
            super (ownername, telephonenumber, chassisNum, color, estimatedVal, year);
            this.owner = new owner(ownername, telephonenumber);
            this.body = body;
            this.type = type;
            this.ccRating = ccRating;
    }
}

I have a Owner class created that has the owner name and telephone number, so I want to get just the ownername and the telephonenumber from that class. but when I try doing it like that. I am getting that error.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    `new owner` should be `new Owner` – ernest_k Mar 01 '20 at 10:45
  • 1
    The field `owner` should **not** be static. – Mark Rotteveel Mar 01 '20 at 10:46
  • 1
    Java is case sensitive. – m0skit0 Mar 01 '20 at 10:46
  • @ernest_k that solved my problem thanks. – dcodinglife Mar 01 '20 at 10:49
  • @MarkRotteveel thanks for that as well. I will be fixing that – dcodinglife Mar 01 '20 at 10:49
  • @MarkRotteveel can you look at the other question I asked. I can't ask multiple questions below 90 minutes at the moment. – dcodinglife Mar 01 '20 at 11:04
  • @dcodinglife no, `static` has nothing to do with inheritance and `super` calls. `static` means that the value of the variable will be shared between all instances of a class. So with `static` every time you do `new Class` the value will be identical, across all instances. Only with non-static variables, the values will be distinct between instances – knittl Mar 01 '20 at 11:19
  • 1
    I have rolled back your edit. You are only supposed to ask one question per question. – Mark Rotteveel Mar 01 '20 at 11:25
  • The 90 minute restriction is designed to encourage people to do more research before they ask questions. (The thinking is: if it is less than 90 minutes since your last question, then you *cannot* have done enough research to find the answer to this one.) Wait 90 minutes, and use the time to see if you can solve the problem yourself. (Hint: ask yourself, what did the original error message *actually mean*? Where is the value for `ownername` supposed to come from? And how?) – Stephen C Mar 01 '20 at 11:36
  • @knittl thanks for that, I was able to solve another problem. – dcodinglife Mar 01 '20 at 11:48

0 Answers0