• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Compile time constants???

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone explain me what compile time constants are???

Thanks in advance...!
 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to my knowledge Compile Time Constants
or just plain compile constants, Officially known as "compile-time constant expressions" these are static finals whose value is known at compile time. e.g.


These can be used as switch case labels, subject, of course, to the usual byte, short, char and int-only restriction.

So conclusion is Compile time constants are evaluated at compile time, and treated as if they were literals, inlined in the code.

Please check this discussion for more examples

JAVARANCH: Compile Time Constants

Hope it helps you. Let me know for any concerns.
[ May 13, 2008: Message edited by: Ankur Sharma ]
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankur
Thank you for the reply & the link that you have provided is quite helpful. But why do we call them as compile-time constants & not runtime constants? My question is after the code gets compiled, does the constant vanish at runtime ? Got my question ???

Thank you
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic