File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strange switch behavior

 
Marcus Laubli
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code:



My problem is in this line of code:

case 14 | 11 | 8 | 5 :

Why on earth do 11 and 5 bite eachother as duplicate labels? Take one out the other is happy and visa versa. Any idea why?

Marcus
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"15 | 13 | ..." is a single int. I know you mean "15 or 13 or ..." But what you're actually doing is bitwise logical operations.

The only way to write what you're trying to do looks like:

 
Marcus Laubli
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ernest. That makes sense. Why didn't I thing of that?

Marcus
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic