• 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 constant

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Please tell me, what is complitime constant?
I read it from SCJP5.0 book written by kethy.

Is there any run time constant ?

Thanks
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please refer the below link,
https://coderanch.com/t/268764/java-programmer-SCJP/certification/Compile-time-constants
 
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Ranchers, please correct me if I'm wrong.

What I get from a compile-time constant is a 'final' identifier declared and assigned a literal value. Something like

Now, obviously this can be either one of the primitives or a String ('cause literals can only be written for them).

The reason such an identifier is called a compile-time constant is that compiler can safely assume the value of the same and for optimal performance, may 'replace' its value whereever it is used in code.

A run-time constant can be thought of as a 'final' identifier which is assigned a value that can be decided only at run-time.

Example,


or


Hope this helps.

- Aditya Jha
reply
    Bookmark Topic Watch Topic
  • New Topic