The problem is that the compiler doesn’t know where the Dog or Cat class is. Here are the steps to telling the compiler how to create a new Dog or new Cat
- Make sure that you have a Dog.java and a Cat.java file in your project. Even if they are in the same folder as your PetsDriver, the compiler won’t know to compile them unless you add them to your netbeans project.
-
Make sure that at the very least Dog.java contains
public class Dog {}
and Cat.java contains
public class Cat {}
-
If the package declaration at the top of Dog.java or Cat.java is not
package Exercise3;
then you must import their package at the top of your PetsDriver1 class so that the compiler knows to look outside the Exercise3 package to find Cat or Dog. (i.e. if Dog.java’s first line is “package Pet;” then in PetsDriver1.java put “import Pet.Dog;” right after “import java.util.Scanner”)
0
solved issue with java code . i cant find my mistake. Dog and Cat are undelined