Linked Questions
49 questions linked to/from Why doesn't Java offer operator overloading?
6
votes
6
answers
5k
views
Java cannot overload any operators. Why? [duplicate]
Possible Duplicate:
Java operator overload
In c++, we can perform the operator overloading. But Java is also a Object oriented language. So why java doesn't support overloading?
1
vote
1
answer
352
views
Java Annotations for Simple Arithmetic on Non Primitive Numbers [duplicate]
Everyone knows how simple arithmetic in Java works for primitives:
int one = 1,two = 2,three = one + two;
double four = (one + two) / three;
if(four % 1 == 0){
System.out.println("Yay for simple ...
3413
votes
36
answers
4.1m
views
Initialization of an ArrayList in one line
I wanted to create a list of options for testing purposes. At first, I did this:
ArrayList<String> places = new ArrayList<String>();
places.add("Buenos Aires");
places.add("Córdoba");
...
119
votes
31
answers
446k
views
C++ performance vs. Java/C#
My understanding is that C/C++ produces native code to run on a particular machine architecture. Conversely, languages like Java and C# run on top of a virtual machine which abstracts away the native ...
210
votes
11
answers
258k
views
Operator overloading in Java
Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it.
111
votes
10
answers
31k
views
Why seal a class?
I'd like to hear what is the motivation behind the bulk of sealed classes in the .Net framework. What is the benefit of sealing a class? I cannot fathom how not allowing inheritance can be useful and ...
18
votes
10
answers
34k
views
Why doesn't Java need Operator Overloading? [closed]
Why doesn't Java need operator overloading? Is there any way it can be supported in Java?
35
votes
3
answers
40k
views
Scala: method\operator overloading
The following example is from the book 'Programming in Scala'. Given a class 'Rational' and the following method definition:
def add(that: Rational): Rational =
new Rational(
this.numer * ...
12
votes
7
answers
46k
views
How do I Implement Operators in a Java Class
I am attempting to create a unsigned integer class.
public class UnsignedInteger extends Number implements Comparable<UnsignedInteger>
{
...
}
Is there a way to implement ...
26
votes
4
answers
35k
views
Compare two objects with "<" or ">" operators in Java
How to make two objects in Java comparable using "<" or ">"
e.g.
MyObject<String> obj1= new MyObject<String>(“blablabla”, 25);
MyObject<String> obj2= new MyObject<String>(“...
11
votes
5
answers
11k
views
Operator overloading in Java
Acordding to my knowledge in java I know, that there is no operator overloading in the Java language.
So, why this code prints 'true' twice ?
String s1 = "abc";
String s2 = "abc";
System....
14
votes
5
answers
9k
views
"+" operator for Java-classes
I have a class like this:
private static class Num {
private int val;
public Num(int val) {
this.val = val;
}
}
Is it possible to add to objects of the class by using the "+"-...
29
votes
1
answer
9k
views
list of ruby operators that can be overridden/implemented
Is there a list anywhere of all ruby operators that can be overridden? (Not the ones that can't!)
16
votes
3
answers
2k
views
Create immutable object, instantiated without new [duplicate]
Can I create a class that instantiates with just the = operator, like the String class does? Or is that a feature specific to String class in Java?
17
votes
2
answers
4k
views
Operator Overloading in Clojure
Even looking closely over documentation on Clojure, I do not see any direct confirmation as to whether or not Clojure supports operator overloading.
If it does, could someone provide me with a quick ...