Stuck on using methods


#1


<Dog.java:5: error: cannot find symbol
age=dogsAge;
^
symbol: variable age
location: class Dog
Dog.java:5: error: cannot find symbol
age=dogsAge;
^
symbol: variable dogsAge
location: class Dog
2 errors.>


I think i definitly followed the instruction ,but it still told me wrong finally, 

class Dog {
int Age;

public Dog(int dogsage) {
age=dogsAge;
    }
  public void bark(){
    System.out.println("Woof!");
    
  }
public static void main(String[] args) {
Dog spike = new Dog(3);
  spike.bark();
    
}
}


#2

here, write age instead of Age

class Dog {
int Age;

and here
inside parameter dogsage should be dogsAge

public Dog(int dogsage) { // 
age=dogsAge;

remember java is case-sensitive.


#3

Thank you so much for your help .

Have a nice day ,


#4

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