Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

interview question

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why java does not support operator overloading?
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java does have some pre-defined overloaded operators such as + which can mean either arithmetic operation or String concatenation depending upon the context, but you can't define your own overloaded operators as you can in C++.

The reason that the architects of Java decided to disallow operator overloading by Java developers is that it can be confusing when you see operators and not know whether they are the ones that are part of the language or whether they are the ones that a developer has overloaded.

In Java, there are not developer-defined overloaded operators, but it is possible for a Java developer to overload methods. Overloaded methods have the same name, but have different type and/or order of parameters.

It can still be confusing when you see a method. You have to ask yourself if there are two methods of the same name whether they are overloaded or overriden and whether they follow the rules to be legal.

Kaydell
[ August 28, 2007: Message edited by: Kaydell Leavitt ]
 
There is no "i" in denial. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic