Did you create a Dog object using the Dog constructor?


#1



class Dog {
  
    int age;

    public Dog(int dogsAge) {

        age = dogsAge;
    }

public static void main(String[] args) {
  
  Dog spike = new age(12);
  
    }
}.


#2

I keep getting this error, Did you create a Dog object using the Dog constructor? Make sure you indicate an integer parameter. i can seem to find were i have gone wrong.


#3

Dog spike = new age(12); //wrong

creating a Dog object using Dog constructor

Dog spike = new Dog(12);


#4

I'm getting the same error:

class Dog {

int age;

public Dog(int dogsAge) {

age = dogsAge;

}

public static void main(String[] args) {

Dog spike = new Dog (5);

}

}

Screengrab


#5

I think it's because you have a space between brackets and dog. Try

Dog spike = new Dog(5);


#6

donmsed is right! remove space


#7

Thanks guys,

Is this just a quirk of this Java console? Should I report is as a bug?


#8

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