Dog.java HELP


#1



cc.jpeg.pdf (410.1 KB)


I can't seem to get passed this.


Replace this line with your code.


#2

Instructions:
Inside of main, use the Dog constructor to create a Dog object and assign it to the variable spike.

so your code should like

public static void main(String[] args) {
    
Dog spike=new Dog(13);

	}

#4

What does the "new" represent? An addition of a new instance/object of a class? A new variable?


#5

Dog spike = new Dog(13);

In this case new simply means create a new object of the Dog class and assign it to the reference variable of type Dog.
The new keyword will make a new object irrespective of whether one of the same type already exists. If the variable it is being assigned to already exists, it will "overwrite" it and create a new object to fit inside of it.

Hope that makes sense.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.