I am writing a program that uses two arrays, one holds int and one holds String. I am using an interface and building a class that implements it. The method in the interface uses a method written like
public void add(E element) throws OverFlowException;
This method is to add an element to one of the arrays depending on what is put in the parameter. My problem is how to differentiate in my class method that implements this method which is which, so I can tell which array the element should add into. My method that implements this is written
public void add(Object element) throws OverFlowException
{
MY CODE HERE.
}
So the question is, how do I identify whether the element is a String or an int when it is passed through the parameter to the implenting method I am writing? I know I have to write an if statement that compares element to String or int, but not sure how to compare the element to the data type. I have only had to write them using the actual value or input in that variable.
Thank you in advance for any help.