Link Details

Unlike C++ java doesn’t provide freedom to programmer to overload the standard arithmetic operators e.g. +, -, * and /, Java has left lot of feature supported in C++ e.g. Java doesn’t support multiple inheritance, no pointers in Java and no pass by reference in java. Rarely this question asked in interview to check how programmer thinks about certain features which java doesn’t have. Though I don’t know the real reason behind it I think following observation make sense on why Operator overloading is not supported in Java.

Posted by marina.sprava  |   Mar 07 2013 / 10:08

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Comments

User 218789 avatar

eelmore replied ago:

Ok, so basically Java doesn't support operator overloading because they think java programmers are too dumb to handle it? That's what it sounds like you said.

Reply 1 votes
User 187417 avatar

sproketboy replied ago:

Java doesn't support it because it's a really bad idea. Only shit languages like C# support shit.

Reply -1 votes
User 218789 avatar

eelmore replied ago:

My, someone sounds a little butt-hurt and at the same time seems to think Java is somehow immune to bad language design. This one little aspect alone is a pretty big flaw. The mere ability to overload operators doesn't make it bad--bad programmers screw it up. Don't blame the very concept of operator overloading. When it makes logical sense to add two objects together "object1 + object2" makes a lot more sense than object1.GetValue().ToPreferredNumericType().WhateverJavaEsqeBS(object2.blahblahblah)

Reply 0 votes
User 187417 avatar

sproketboy replied ago:

Dude if you don't understand why operator overloading is a bad idea then you're a fuktard loser.

Reply -1 votes
User 218789 avatar

eelmore replied ago:

sure thing, kid.

Reply -1 votes
User 187417 avatar

sproketboy replied ago:

Glad you agree.

Reply -1 votes
User 218789 avatar

eelmore replied ago:

Whatever you say, kid.

Reply -1 votes

Recommended Links

Scala
Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Apache Hadoop
  2. Play
  3. Akka
  4. Debugging JavaScript
  5. Design Patterns
  1. Apache Hadoop
  2. REST
  3. Java
  4. Git
  5. Java Performance
Connect with DZone