/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testelimination3;
import java.util.Scanner;
/**
*
* @author Nick
*/
public class TestElim {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Please enter a set of numbers");
int[] numbers = new int[10];
for(int i = 0; i < numbers.length; i++){
numbers[i] = input.nextInt();
}
System.out.println("Without Duplicates: ");
}
public static void printArray(int[] newArray){
for(int i = 0; i < newArray.length; i++){
System.out.print(newArray[i] + " ");
}
}
public static int[] eliminateDuplicate(int numbers[]){
int[] newArray= new int[numbers.length];
for(int i = 0; i <numbers.length; i++ ){
for(int j = 0; j < newArray.length; j++ )
{
if(newArray[j] == numbers[i]) {
break;
}
}
newArray[newArray.length] = numbers[i];
}
return newArray;
}
}
Hi everyone, i am new to java coding so bear with me haha. I need to create a program that takes in an arrary and checks it for duplicates, then returns the new array without any duplicates. I haveto use a method and i cannot use hashsets or anything like that. When i run the program it doesnt work and sometimes gives me errors. What i have so far is listed below. Any help is appreciated. Thanks!!!