please post your code
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(20);
spike.bark();
}
I m calling bark function using spike object
its showing error
i m learning java in codecademy
This is regarding OOP in java
Can I have the link to the lesson?
this is the link
I can’t figure out what’s wrong, so you should reset your code, and try one more time to call the bark method on spike, inside of the main method.
ok thanks
actually,its not compiling
I figured out what’s going on,
System.out.println("Woof!"); }
^
} public static void main(String[] args) {
^
right here, you have two closing brackets, so you need to delete of one of them, and then put one at the very end of your code.
I did that
I removed one curly bracket
Still its showing error
not compiling
Yes done
Thanks a lot
no error
Glad I could help.
ya sure
Let me introduce myself
I m akshay dharmapuri
doing btech final year
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.