This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is compile time constant in switch case?

 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi,
what is compile time constant in switch case?




why the above code doesn't work?

Thanks!
regards
samura


 
Juwonlo Ibigbami
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code:
---------------------------------------------------------------------------

final int a =1;
final int b;
b = 2;
int x =0;
switch(x)
case a: //ok
case b: //compiler error

---------------------------------------------------------------------------

your variable a and b should be a constant and should be declear as final ans static with iniialised value
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic