import java.util.Scanner; public class duplicate { String[] $numbers = {"", "", "", "", ""}; //set the array spaces //get the numbers to be saved in the array from the user public void askNumbers(){ Scanner input = new Scanner(System.in); String number; //declare number //loop 5 times to add numbers to the array for(int i=0; i < 5; i++){ System.out.print("Enter a Number: "); number = input.nextLine(); //check if the numbers is duplicate if (!isDuplicate(number)){ //write the number in the array if its not a duplicate number $numbers[i] = number; }else{ System.out.println("The number already is in the array"); } //display number to the user System.out.println(" " + $numbers[i] + " " ); } } //check duplicate number function public boolean isDuplicate(String number){ boolean result = false; //set result to false //loop in the array to compare each value in the array with the number for(int i=0; i < $numbers.length; i++){ //if the numbers are equals then set result to true if($numbers[i].equals(number)) { result = true; } } return result; }