I am using generics in java, and I want to know how I can test to see if I have a int or a float? Is there some sort of type-testing? I'm sure there is, I just need someone to help point me in the right direction. Thanks!
paradox814 1 Posting Whiz
Recommended Answers
Jump to Posthuh?
What are you trying to do?
If you have to worry about the exact type of a genericised argument to a method the decision to use generics at that stage was wrong.
Jump to PostIf your method implementation can work with both integer and floating point numbers, why handle them differently?
If it can't, why use generics to template away the difference in the method signature?I assume you pass in an argument of type <E extends Number> ?
All 6 Replies
jwenting 1,905 duckman Team Colleague
paradox814 1 Posting Whiz
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
paradox814 1 Posting Whiz
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
jwenting 1,905 duckman Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.