1 svar
167 visningar
sale 48
Postad: 15 jul 2020 09:29

basic question

Hi,

I have a class dog which has attribute owner which I set to null when dog is created as below.

but when I try to access owner attribute in another class i don't get null iställed I get Owner =application.User@47f37ef1 

while I am expecting null. Why it is so.

thanks for reply.

public class Dog
{
private String name;
private int age;
private String breed;
private int weight;
private double tailLength;
private User owner;


public Dog(String name, String breed, int age, int weight)
{

this.name = name;
this.age = age;
this.breed = breed;
this.weight = weight;
this.owner = null;

}

sale 48
Postad: 15 jul 2020 10:32

Hi again,
I found the misstake. Somewhere in the code owner attribute got a value and is no more null.
thanks

Svara
Close