AH! I have a list of strings... and i just want to remove an element from the list if it is ""
but i keep causing the program to crash. How do i get around this? I made a list of arrays into a List of strings thinking i could remove it that way. Here is what i have:
List<String>list;
String[] f= new String[file.length()];
f= file.split("<");
list= Arrays.asList(f);
final Iterator<String> iter = list.iterator();
while (iter.hasNext())
{
final String temp = iter.next();
// TODO check for zero-length arrays
if (temp.equals(""))
{
iter.remove();
}
}
Error:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(Unknown Source)
at java.util.AbstractList$Itr.remove(Unknown Source)
at utilities.Validation.Validate(Validation.java:44)
After i convert it to a List, i can print the list just fine.. it's removing elements from it that becomes an problem...
finalkeyword? Have you tried removing them?