Edited to add:I don't think this question is really what you want, based on your comment to the original question. I'll post a comment on the other question to try and offer some assistance to yoru real issue.
As Bill the Lizard says, you'll know at compile time what type a primitive is:
public void foo(int x, double y){...}
On the other hand, if you're putting your types inside another object, like
Vector v = new Vector();
v.add((int)1);
v.add((double)1.0));
then you're really dealing with objects not primitives. Each primitive has a corresponding class:
- int has Integer
- double has Double
- float has Float
- boolean has Boolean
- etc.
You can use the instanceof keyword to determine what type you're dealing with (you can do this with any class):
if( x instanceof Double ) {
doDoubleThing();
} else if( x instanceof Integer ) {
doIntegerThing();
} // and so on