I made this code from the book "Head First Java 2nd Edition"(pages 95 and 96). It compiles fine, however, when one runs the program it gives the following error "exception in thread main java.lang.NullPointerException" This error occurs on line 21, most likely due to a variable that was set to Null. I cannot figure out what that variable is, and/or how to fix it. Any suggestions?
class Dog{ int size; String name; void bark(int numOfBarks){ while(numOfBarks>0){ if (size>60){ System.out.println("Woof! Woof!"); }else if(size>14){ System.out.println("Ruff! Ruff! Ruff!"); }else{ System.out.println("YIP!! YIP!! YIP!! YIP!!"); }//end if/else numOfBarks=numOfBarks-1; }//end loop }//end bark }//end class Dog class DogTest{ public static void main(String[] args){ Dog[] Dog=new Dog[3]; Dog[0].size=63; //error occurs here Dog[1].size=8; Dog[2].size=35; System.out.println("Bark! Bark, all of ye! Bark, all my dogs!!"); Dog[0].bark(1); Dog[1].bark(4); Dog[2].bark(2); }//end main }//end class DogTest