• Post Reply Bookmark Topic Watch Topic
  • New Topic

| operator used as a conditional operator  RSS feed

 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I had let eclipse generate some code for me, and I saw this:



I have not yet encountered exceptions being used with the | operator.
Has it always been part of Java or is it a new addition?
If it is a new addition, what feature did it come under.

I just want to read more about it as I don't remember coming across this syntax for my SCJP ,,,

Thanks.
Mathew
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the meaning of | in this case is not as a conditional operator.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does mean “or”, as the | operator does elsewhere. An example of how clever Sun and Oracle have been in reusing old operators so no new keys are required and the only keywords not in Java1.0 are enum strictfp and assert.

But enum and assert ought to have been there from the start.
 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all. The Big Moose Saloon still has lots of friendly folks who can answer questions.

 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!