stop a loop from asking user input
<p>problem here is that we want the program to stop the loop/stop asking integers when '-1' is inputted by the user that it wont have to get the maximum length of our array</p>

<pre><code>import java.util.Scanner;
public class DELETE DUPLICATES {
public static void main(String[] args) {
        UserInput();
        getCopies(maxInput);
        removeDuplicates(maxInput);
}
static int[] maxInput= new int[20];
static int[] copies = new int[20];
static int[] duplicate = new int[20];
//get user's input/s    
public static void UserInput() {
  Scanner scan = new Scanner(System.in);
        int integer = 0;
        int i = 0;
  System.out.println("Enter Numbers:  ");
        while(i &lt; maxInput.length)
        {
                integer = scan.nextInt();         
                maxInput[i] = integer;
                        i++; 
                        if (integer == -1) 
                            break;  
        }
                  int j = 0;
        for(int allInteger : maxInput) {
                System.out.print(allInteger+ "  ");
                j++;
        }
}
//to get value/number of copies of the duplicate number/s
public static void getCopies(int[] Array) {
   for(int allCopies : Array) {
    copies[allCopies]++;
}

for(int k = 0; k &lt; copies.length; k++) {
    if(copies[k] &gt; 1) {
        System.out.print("\nValue " + k  + " : " +  copies[k] + " copies are detected");

    }
        }
        }
//remove duplicates
public static void removeDuplicates(int[] Array) {
 for(int removeCopies : Array) {
     duplicate[removeCopies]++;
    }

    for(int a = 0; a &lt; duplicate.length; a++) {
        if(duplicate[a] &gt;= 1) {
            System.out.print("\n"+a);

        }
            }
  }
 }
</code></pre>

<p>Example:
If we input :
1
2
3
3
4
5
-1</p>

<pre><code> The result of our program is : 1  2  3  3  4  5  -1  0  0  0  0  0  0  0  0  0  0  0  0  0
 We want the result to be like: 1  2  3  3  4  5
</code></pre>

<p>We need your help guyz . practicing our programming 1 subject hope we could get some help here</p>
