Error: class Dog is already defined in package unnamed package

class Dog {

class Dog extends Animal {

int age;

public Dog(int dogsAge) {

age = dogsAge;


public void bark() {



public void run(int feet) {

System.out.println("Your dog ran " + feet + " feet!");


public int getAge() {

return age;


public void main(String[] args) {

Dog spike = new Dog(5);
int spikeAge = spike.getAge();




Delete the first line and start with class Dog extends Animal {
At the moment you have two classes and do not forget to delete the last } as it relates to the first class you created.

Let me know if that solves your question. Also if you feel that your question was solved, to mark it as such.

Hope that helps.

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