Can someone explain why, when I input 'mytag' it does find it? When I debug, it shows the text matches, but the IDs are different. Not sure why that would matter?
public void RemoveTag() throws IOException, NoSuchTagException{
System.out.printf("Tag to delete: ");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String tempTagText = reader.readLine();
for (int i = 0 ; i < tags.size() ; i++)
{
if (tempTagText == tags.get(i).getTagName().toString())
{
tags.remove(i);
System.out.println("Tag " + tempTagText + " removed.");
return;
}
}
throw
new NoSuchTagException("The entered text does not match any tag");
}
}
package main;
public class Tag {
public Tag(String name) {
tagName = name;
tagID = nextTagID;
nextTagID++;
};
private static int nextTagID = 0;
public void setTagName(String name)
{
tagName = name;
}
public String getTagName()
{
return tagName;
}
public String tagName;
public int tagID;
}