operators

G

Guest

I have a class Digit and I want to implement operators + - * / with 2
Digits, a Digit and an Integer, a Digit and an int, a Digit and a Double
etc.

Is this possible?
 
C

Chris Smith

I have a class Digit and I want to implement operators + - * / with 2
Digits, a Digit and an Integer, a Digit and an int, a Digit and a Double
etc.

Is this possible?

Nope, there is no user-defined operator overloading in Java.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
O

Oscar kind

Chris Smith said:
Nope, there is no user-defined operator overloading in Java.

This is also why these operators are not implemented for the classes
java.math.BigInteger and java.math.BigDecimal.

You can however, use the same solution as used for those classes: create
methods for it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top