How do I add 1 element to array with loops? : <p>I'm trying to loop through array and if element is null I will add a string inputted by the user. When I run it, it spits out the loop however big my array is. I want just to add 1 string and go back to a switch. How do i go about this?</p>

<pre><code>public void insertNames() {
    int i;
    for(i=0; i &lt; names.length; i++) {
        if(names[i] == null) {
            System.out.println("Enter name: ");
            names[i] = input.toString();
            while(i == names.length); {
                System.err.println("Array is full, cannot add any more elements");
</code></pre>

<p>I expect just looping through till I find null and adding string inputted by user and go back to switch
Im experiencing when I find null it will prompt user for input, but then move to the next element</p>
