File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

switch statement and compile time constatns.

 
Jan Osykowski
Ranch Hand
Posts: 41
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, thanks for the answers!
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic