So I am trying to compare two char arrays, and all letters that are present in keyW, should be removed from the array invAlphabet. I have been able to find the duplicates inside the invAlphabet array, however, I don't know how to remove the duplicate elements without using Lists or Collections which I should not use... Any idea?
public static void main(String[] args)
{
final int SIZE = 26;
char[] keyW = {'A', 'L','O'};
char[] invAlphabet = new char [SIZE];
for (int i = 0; i < SIZE; i++)
{
invAlphabet[i] = (char)('Z' - i);
}
for (int i = 0; i<keyW.length; i++)
{
for (int j = 0; j < invAlphabet.length; j++)
{
if(keyW[i] == invAlphabet[j])
{
//need to delete the invAlphabet[j] elements that are duplicates
System.out.println(invAlphabet[j]);
System.out.println(j);
break;
}
}
}
}