title: Java array, add item into next empty index
body: <p>In Java, is there a way to add a value not at a specific index, but to the next undeclared index? Say: </p>
  
  <pre><code>int[] negativeArray = new int[21];
  int[] positiveArray = new int[21];
  </code></pre>
  
  <p>There are two arrays for two different types of ints, for example negative and positive. I'm looping through this, and I want it to work something like a stack (I don't know too much about stacks, but to my knowledge you don't go through its index, you just pop/push items onto it) to where if its a negative number, put in the number in the next undeclared index spot in the negative array.</p>
  
  <p>I thought of a way to do this with some extra code. I'd set all values in the array to 0. When checking if the variable is negative or positive, I would loop through the array to the next value that is 0. Once I find it I know what index I'm on. This would require a bit of effort though, are there any simpler ways of doing this? </p>
  
  <hr>
  
  <p>Edit: Some comments are stating different ways to do this without using a basic array. I was assigned this, and I am required to use an array to get credit for it...</p>