• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

| operator used as a conditional operator

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a multiple catch feature.
It was added in Java SE 7.

http://docs.oracle.com/javase/tutorial/essential/exceptions/catch.html
http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the meaning of | in this case is not as a conditional operator.
 
Marshal
Posts: 76085
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 76085
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
reply
    Bookmark Topic Watch Topic
  • New Topic