Here are a few facts for you:
You can't put primitive values in a Collection (generic types can only bind to reference types)
If you necessarily need to put both chars and doubles (or Charactersand Doubles taking the above point into consideration) you need to declare the list to contain the least common subtype of Character and Double which is Object:
List
this will however not disallow Strings and Integers.
Here's how I would solve it:
class MyDatatype {
....
}
class MyDatatypeCharVariant extends MyDatatype {
char data;
...
}
class MyDatatypeDoubleVariant extends MyDatatype {
double data;
...
}
and then declare the list as:
List someList = new ArrayList();