1 svar
78 visningar
sale 20
Postad: 15 jul 2020

basic question


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 20
Postad: 15 jul 2020

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

Svara Avbryt