I have a class like this:
public class Foo<T>
{
//What ever inside
}
And later on I want to do something like this:
public class MyClass
{
Foo foo;
public MyClass(int x)
{
if(x==1)
{
foo = new Foo<Integer>();
//EDIT1
handleFooWhenItIsInteger();
//EDIT1
}
else
{
foo = new Foo<String>();
//EDIT1
handleFooWhenItIsString();
//EDIT1
}
}
assume that I do some integer work in function 'handleFooWhenItIsInteger()' and with some string in another one.
Is defining 'foo' like above OK?