Getting error: incompatible types: int cannot be converted to T. I want to build a queue using linked list that can store items of different data types. Please suggest ways on how can i pass values belonging to different data types into the generic function add().
public void main(String args[])
{
MyQueue<T> q=new MyQueue<T>();
q.add(10);
q.add("Hello");
}
public void add(T item)
{
QueueNode<T> t=new QueueNode<T>(item);
if(last!=null)
{
last.next=t;
}
last=t;
}