File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Compile Time Constants... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Compile Time Constants..." Watch "Compile Time Constants..." New topic
Author

Compile Time Constants...

Dan Silva
Ranch Hand

Joined: Sep 05, 2007
Posts: 86
What does it mean to be a compile time constant?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A compile time constant is one that can't be set or changed after compilation.

Examples:


The first is a compile time constant.
The compiler knows that the value will be 1 and that it can never change.

In the second example the assignment of SET_AT_RUNTIME is delayed until the construction of the class. The compiler has no idea what SET_AT_RUNTIME will be.

In the third example the value depends on another class which could change after this class has been compiled so it isn't a compile time constant.
[ March 01, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Dan Silva
Ranch Hand

Joined: Sep 05, 2007
Posts: 86
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compile Time Constants...