I keep getting an error that says: Note: ABag.java uses unchecked or unsafe operations.
I googled it and found this post, and made the changes that I thought would remove the error but I continue to get the error.
Is there anything else I can do to stop getting this error message?
public class ABag<Item> implements BagInterface<Item>
{
private ArrayList<Item> bag;
//creates an empty bag
public ABag(){
bag = new ArrayList<Item>();
}
//creates an empty set with initial capacity
public ABag (int initialCapacity){
bag = new ArrayList<Item>(initialCapacity);
}
public boolean add(Item newEntry){
if (newEntry == null)
return false;
else
{
bag.add(newEntry);
return true;
}
}
public boolean isFull(){
return false;
}
public Item[] toArray(){
Item[] temp = (Item[])bag.toArray();
return temp;
}
public boolean isEmpty(){
return false;
}
public int getCurrentSize(){
return bag.size();
}
public int getFrequencyOf(Item anEntry){
int count = 0;
if (!(bag.contains(anEntry)))
{
for (int i=0;i<bag.size();i++)
{
if (bag.get(i) == anEntry)
count++;
}
}
return count;
}
public boolean contains(Item anEntry){
return bag.contains(anEntry);
}
public void clear(){
bag.clear();
}
public Item remove(){
int size = bag.size();
Item removed = bag.remove(size-1);
return removed;
}
public boolean remove(Item anEntry){
return bag.remove(anEntry);
}
}
Thank you in advance!