• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overloaded Operators

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is "+" the only overloaded operator in Java or are there any others.
 
victor kamat
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "+" operator is overloaded for Strings - as most people know.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by victor kamat:
Is "+" the only overloaded operator in Java or are there any others.


The short answer is that "+" is the only overloaded operator.

But note that |, &, and ^ can be applied to either numeric operands (where they act as bitwise operators) or to boolean operands (where they act as logical operators).

I don't regard this as overloading, because these logical operations are really the same as bitwise operations applied to a single bit (true or false). But since the bit format of a Java boolean is not specified, I suppose one could argue that it is a form of overloading.
[ August 07, 2007: Message edited by: marc weber ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic