I'm making an ArrayList that takes Strings, and one method in the class takes a String, adds "urgent:" to the front of it, and puts it at the beginning of the list. I'm now writing a method that is supposed to take an int, a String's position, and 'demote' that string to the end of the list.
However, if the string has "urgent:" in front of it, the method is also supposed to remove "urgent:" if it's demoted. Everything compiles and runs, but it's not removing "urgent:" and I'm not sure why.
public void addUrgetItem(String newItem) {
String urgentItem = newItem;
items.add(0, "urgent: " + urgentItem);
}
public void demote(int position) {
int size = items.size();
String itemAtSpot = items.get(position);
items.remove(itemAtSpot);
items.add((size-1), itemAtSpot);
if (itemAtSpot.startsWith("urgent:")) {
items.remove("urgent:");
}
}