Say I have a method declaration like:
private void someMethod(final String someKey, final Object dataType){
// Some code
}
I want to call it like:
someMethod("SomeKey", String);
someMethod("SomeKey", Date);
I can it do it in different ways like declaring an int with different values representing the type, an enum, or the like.
But can I just pass the type itself?
EDIT:
To elaborate, I can do like:
someMethod("SomeKey", 1); // 1 = String
someMethod("SomeKey", 2); // 2 = Date
This doesn’t look good.
If you’re looking to pass the type of object as a parameter, you can do it by passing a
java.lang.Classi.e.
Is that what you’re looking for?
edit: incorporating Mark’s comment.
You can call this like
etc.