• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compile Time Constant

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you exactly mean by stating that a field is a
compile time constant
Please explain ???
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is some info I found that should be helpful.

A compile-time constant is a value that can be (and is) computed at compile-time. A runtime constant is a value that is computed only while the program is running. If you run the same program more than once:

A compile-time constant will have the same value each time the application is run.
A runtime constant can have a different value each time the application is run.
 
Prashanth Lingala
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Very Much

Regards
Prashanth Lingala
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you encountered the term when you read that there is a big-time gotcha with respect to compile-time constants. Consider the following scenario...



Now, if you compile these two java files and run class B, it will print out, "Hello". If you then change the "MESSAGE" variable in A.java to "Hello, World", compile A.java, and then run class B again, it'll print "Hello" still! It will not lookup the value of the "MESSAGE" variable dynamically at runtime. So, be careful. It helps if you use an IDE which keeps track of that stuff and knows that B needs to be recompiled because one of its dependencies has changed.
[ March 08, 2005: Message edited by: James Carman ]
reply
    Bookmark Topic Watch Topic
  • New Topic