J
justineee
Hi everyone,
this is a code implemented in a button in my program.
I tried to convert the array into a list to remove a specific element
then convert it back to an array.
It has no errors but when I press the delete button.. nothing
happens.. is there anything wrong with my if statements??
also, is "arrayWordsC.toArray(arrayWords);" correct? I want to convert
the List arrayWordsC to an array named arrayWords??
if (jnd.getSource()==deleteButton)
{
arrayWordsC = Arrays.asList(arrayWords);//this is a list
getInputDelete = inputDelete.getText();
if (!(getInputDelete.equals("")))
{
int dCtr;
for (dCtr = 0; dCtr < arrayWords.length; dCtr++)
{
if (arrayWordsC.get(dCtr)==getInputDelete)
{
arrayWordsC.remove(dCtr);
textArea.setText(" Welcome to E-
Dictionary v1.0\n\n");
mBox.setText("The word "+inputDelete+" has been\ndeleted in the
dictionary.");
}
}
arrayWordsC.toArray(arrayWords);
}
else
mBox.setText("a");
inputDelete.setText("");
}
thanks!
this is a code implemented in a button in my program.
I tried to convert the array into a list to remove a specific element
then convert it back to an array.
It has no errors but when I press the delete button.. nothing
happens.. is there anything wrong with my if statements??
also, is "arrayWordsC.toArray(arrayWords);" correct? I want to convert
the List arrayWordsC to an array named arrayWords??
if (jnd.getSource()==deleteButton)
{
arrayWordsC = Arrays.asList(arrayWords);//this is a list
getInputDelete = inputDelete.getText();
if (!(getInputDelete.equals("")))
{
int dCtr;
for (dCtr = 0; dCtr < arrayWords.length; dCtr++)
{
if (arrayWordsC.get(dCtr)==getInputDelete)
{
arrayWordsC.remove(dCtr);
textArea.setText(" Welcome to E-
Dictionary v1.0\n\n");
mBox.setText("The word "+inputDelete+" has been\ndeleted in the
dictionary.");
}
}
arrayWordsC.toArray(arrayWords);
}
else
mBox.setText("a");
inputDelete.setText("");
}
thanks!