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.
hg_fs2002
13
Light Poster
Recommended Answers
Jump to PostThe Java Language Specification has the definitions of how each each type of constant ("literal" in Java-speak) is represented/defined. See section 3.10
http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10
All 3 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
hg_fs2002
13
Light Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
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.