java - Shifting Parts of an Array and NullPointerException -


This is the piece of the overriding method, which adds to ArrayList. I intend that to keep the list alphabetically For comparison (by comparing strings, compare is defined in a different method), this will use comparisons. To determine whether the elements should be moved correctly (to find the list or string "smaller" than string arg0), and then insert an arg0, until one goes wrong in one position. There was no error while adding the first element, but when a second element was added to ArrayList then a NullPointerException was raised. How do I fix the NullPointerException problem, but still there are problems within the method.

Given that an arr arr [] is already defined (with length of 20), and arg0 already passed already:

  int example = This.size (); While (example & gt; 0 & amp; amp; and amp0.compareTo (arr [instance-1]) gt; 0) {arr [example] = arr [Example - 1]; Instance--; } Arr [example] = arg0; Back true;  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -