Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

switch statement and compile time constatns.

 
Jan Osykowski
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I have a question about the switch construction. In the book it's written that the case constant must be a compile time constant and thus i have a question to this code:



And it works but I think that b+ 2*b is not a compile time constant. What do you think? On the other hand this code doesn't work:



Why it's like this?

Cheers,
Jan.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, if you mix your compile time constant with non-compile time constant then result become non-compile time constant

 
Malatesh Karabisti
Ranch Hand
Posts: 153
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile time constant will be formed only with Rules
 
Jan Osykowski
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, thanks for the answers!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic