• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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 ]
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic