what is the reason for needing both of the lines of code? how come just the first line wont work?
Those 2 lines do 2 different things and you need both of them.
One of them (public ArrayList BallRectangle;) declares your variable. It gives it an access modifier (public), a data type (ArrayList) and a name (BallRectangle).
The other line (BallRectangle = new ArrayList();) assigns a value to your variable. It constructs an object (new ArrayList()) and then assigns the result of that statement (in this case, a newly reserved block of memory for an ArrayList) to the variable on the left side of the equal sign (BallRectangle).
If you declared the variable and then tried to use it without assigning a value to it, the variable would have its default value. For data types that are not primitive data types (primitive data types: http://docs.oracle.c.../datatypes.html), that default value is null. This is where something should come full circle for you and register as something you've definitely seen before... If you try to call a method or access a field on a null object, you get a NullPointerException. I know you've seen that exception once or twice. And that process is the reason.
Declare: public ArrayList ballList;
Use: ballList.add(new Ball());
If you go straight from declaring to using, the Use line would throw a NullPointerException.