Find the error(s) in the following code. The rectangleArray is an instance variable of type ArrayList, which contains MyRectangle objects.
```
1 private void paintComponent( Graphics g )
2 {
3 superclass.paintComponent( g );
4 Iterator traverse = rectangleArray.iterator();
5
6 while ( traverse.hasMoreElements() )
7 {
8 MyRectangle currentRectangle = ( MyRectangle ) traverse.next();
9 currentRectangle.drawMyRectangle( g );
10
11 } // end while
12
13 } // end method paintComponent
```
To call the paintComponent method of the superclass, use keyword super. Also, in the while loop, to determine if there are remaining objects in the rectangleArray, use the hasNext method as opposed to the hasMoreElements method.
```
1 private void paintComponent( Graphics g )
2 {
3 super.paintComponent( g );
4 Iterator traverse = rectangleArray.iterator();
5
6 while ( traverse.hasNext() )
7 {
8 MyRectangle currentRectangle = ( MyRectangle ) traverse.next();
9 currentRectangle.drawMyRectangle( g );
10
11 } // end while
12
13 } // end method paintComponent
```
You might also like to view...
A table presents information in ________ and rows
Fill in the blank(s) with correct word
What is secondary color correction?
What will be an ideal response?
Every time you click an icon on your desktop, tap commands on a touch screen, or follow a link on your tablet, you are using software.
Answer the following statement true (T) or false (F)
If pt is declared as a pointer to a structure of type Employee, ____ refers to the variable whose address is in the pt.idNum variable.
A. (*pt).idNum B. *pt.idNum C. pt->idNum D. (*pt.)idNum