+ 3

A method that multiplies two objects in java

is it possibile? if yes how it's achieved?

11th Apr 2017, 7:13 PM
Leonardo Brocchi
5 Answers
+ 11
@Andrey Yes, it's overloading of course, sry for that. He asked for Java (tags).
12th Apr 2017, 4:42 AM
Tashi N
Tashi N - avatar
+ 9
Well, you cannot override the operator * but you can create a method named multiply and do whatever you want to do there.
11th Apr 2017, 7:31 PM
Tashi N
Tashi N - avatar
+ 8
please explain what you are trying to mutliply and what kind of object. this way we may help
11th Apr 2017, 7:53 PM
Edward
+ 6
@Tashi N Yes, I've checked language tags. But if we are still talking about operators overloading it is not possible in Java and possible in C++ so I've mentioned C++.
12th Apr 2017, 4:45 AM
Andrew Harchenko (Tomsk)
Andrew Harchenko (Tomsk) - avatar
+ 5
@Tashi N As far as I know it's called "overloading" (not overriding). It's in most context... and surely for C++ where operator overloading exists. "Overriding" is a term for virtual functions/methods overriding. Here you can check: http://stackoverflow.com/questions/3803970/what-is-the-difference-between-operator-overloading-and-operator-overriding-in-c
11th Apr 2017, 10:18 PM
Andrew Harchenko (Tomsk)
Andrew Harchenko (Tomsk) - avatar