In a word yes, and I usually do comment after I'm finished.
This is what I came up with. It works fine, and will be perfect for me but surely there's a better way.
Thanks,
Chris
import java.util.Scanner;
public class FML{
public static void main(String[] args){
Scanner kbd = new Scanner(System.in);
int[] array = new int[10]; // Test array
String instr1 = "Enter 10 integers"; // instructions
String instr2 = "\nInt: "; // Loop instructions
String reply = "The Distinct numbers are: "; // Distinct reply
System.out.print(instr1); // instructions
for(int i =0; i<array.length; i++){ // get the ints
System.out.print(instr2);
array[i]=kbd.nextInt();}
int[]distinctArray = saveDistinctNumbers(array); // Call the save distinct method
System.out.println (reply); // initial reply
for(int element: distinctArray){ // Print the distinct array
System.out.print (element + " ");}
}
public static int[] saveDistinctNumbers(int[] array){
boolean[] checker = new boolean [array.length]; // Bool array for finding distincts
int[] temp = new int[array.length]; //temp array to pass distinct to return
for(int i = 0; i<array.length; i++){ // uses bool array to id repeat ints
for(int j = 0; j < array.length;j++){
if(array[i] == array[j] && i != j)
break;
if(array[i]!= array[j]){ // if is not a repeat
checker[i] = !checker[j];}}} // makes the index at j true
int truecount = -1; //allows temp[]to move through index at a different rate than array[]
int totalcount = -1; //allows array[] to move through index at a different rate than temp[]
for (int element :array){ // for array[]
totalcount++; //totalcount++ treated like i in a for loop
if(checker[totalcount]){ // if checker[totalcount] is true
truecount++; //truecount ++
temp[truecount] = array[totalcount];}} //filters out the spaces between repeats
int[] distinctArray = new int[truecount+1]; // properly formatted distinct array for return
System.arraycopy(temp,0, distinctArray,0, distinctArray.length); //copy temp to distinct
return distinctArray;} //return distinct.
}