Error on 4/13 Classes: Instance Variable


#1



https://www.codecademy.com/en/courses/learn-java/lessons/object-oriented-programming/exercises/classes-instance-variables


I put in the code and keep getting an error. After trying different things, I still do not get help or the correct code. I am not sure what I am doing wrong. The error asks me "Did you create an instance variable called age? Place it inside of the class, but before the Dog constructor." Please help!


Below is my code: 
class Dog {
  
  **int modelAge;**

	public Dog() {
  
  }


	public static void main(String[] args) {

	}

}


#2

Try removing the '*' and renaming the variable, form "modelAge" to "age".


#3

Hello, thanks for the response. I still got an error when I tried that..


#4

Add the 'public' access modifier before class Dog. That should work. :slight_smile:


#5

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