Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li>I don't see where you create a new instance of the <code>char</code> array. Any reference to it will generate a <code>NullPointerException</code></li> <li>I don't see the declaration or implementation of <code>ArrayList.insertEnd(..)</code> which would generate a compilation error, so I'm assuming you have not included it here (same goes for <code>deleteEnd</code> and <code>expandByTen</code> etc).</li> <li>Assuming you are creating the <code>char[]</code> instance somewhere with the length defined in the constructor, you set the size equal to 10 if the constructor argument is less than or equal to zero. In the <code>main</code> method, you instantiate an instance of <code>ArrayList</code> with a size of -1, which should (based on what little you have provided) create (somewhere) an instance of the <code>list</code> field with a size of 10. However, your first loop attempts to make 15 iterations, which will generate an <code>IndexOutOfBounds</code> exception at runtime if you aren't doing appropriate bounds checking in the <code>insertEnd</code> method.</li> </ul> <p>I'm going out on a limb and guessing you are doing this as an assignment for school? If not, be aware that Java has a whole plethora of containers, including <a href="http://docs.oracle.com/javase/7/docs/api/index.html?java/util/ArrayList.html" rel="nofollow"><code>java.util.ArrayList</code></a>, in the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/package-summary.html" rel="nofollow"><code>java.util</code></a> package. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload