Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What is the "Compile time constant" norm for a switch case constant ?

843789Oct 30 2009 — edited Oct 30 2009
Hi Guys,

AS per the Kathy Sierra written book for SCJP 1.5 :

The case constant for a switch statement must be a compile time constant,only final is not enough.

Now,what is a compile time constant ?

Don't even integers which are declared normally ( For ex. int k=5;) act as case constants in a switch statement ?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2009
Added on Oct 30 2009
19 comments
716 views