My public class isn’t declared within the program

With the program below I had created, it won’t allow me to run it as it claims that the class is public and should be declared. How can I fix it so that I can run my program successfully. Thanks

code :

public class DogTest {
    public static void main(String args[]){ // this is the beginning of the methd 
        Dog dog1= new Dog();
        dog1.name = "Bart";
        dog1.size= 100;
        Dog[] myDogs = new Dog[2]; // here is where the array of the dogs begins and it has already set the position to 2 
        myDogs[0]= new Dog();
        // my dogs is a new class 
        myDogs[1]= dog1;
        myDogs[0].name="Fred";
      myDogs[0].size= 43;