I am writing a program that needs to know the type of constants. I am wondering if there is any way of getting this in java? Like for constant "2" type is int and for "2.0" type is double.
Jump to Post
The Java Language Specification has the definitions of how each each type of constant ("literal" in Java-speak) is represented/defined. See section 3.10
All 3 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.