Using method
I cannot give name to dog. Pls help me name my dog! class Dog { int age; String name; public Dog(String dogName){ name = dogName; } public Dog(int dogsAge) { age = dogsAge; } public void bark() { System.out.println("Woof!"); } public void run(int feet) { System.out.println("Your dog ran " + feet + " feet!"); } public int getAge() { return age; } public String dogName() { return name; } public static void main(String[] args) { Dog spike = new Dog(5); Dog spike = new Dog("Spike"); spike.bark(); spike.name(); spike.run(40); int spikeAge = spike.getAge(); String spikeName = spike.dogName(); System.out.println("Your dog " + dogName + " is " + dogsAge + " years old"); } }