By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,560 Members | 2,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,560 IT Pros & Developers. It's quick & easy.

How to add 2 numbers(integers,floats,..etc. In JAVA language

P: 2
How to Add 2 Numbers ?
Sep 9 '07 #1
Share this Question
Share on Google+
6 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Ashok. Welcome to TSDN!

I'm going to go ahead and move this thread to the Java forum, where our resident Experts will be better able to help you out.
Sep 9 '07 #2

Ganon11
Expert 2.5K+
P: 3,652
...with the '+' operator?
Sep 9 '07 #3

Expert 10K+
P: 11,448
...with the '+' operator?
Java is not C++; Java is much more clumsy than that: the Number class is the
abstract superclass of many classes that implement the 'add' operator but one
has to use the 'instanceof' operator or deal with 'ClassCastExceptions' in order
to just add two Numbers. Don't blame me, I didn' invent that language ;-)

Of course for primitives Java behaves like a full blown programming language and
that '+' operator is implemented for convenience.

kind regards,

Jos
Sep 9 '07 #4

Ganon11
Expert 2.5K+
P: 3,652
I simply assumed that, since every other word in the OPs question was capitalized, that his/her question was "How to add 2 numbers," not necessarily referring to any specific class or type, but instead referring to ints, doubles, floats, etc. etc.
Sep 9 '07 #5

pbmods
Expert 5K+
P: 5,821
... and that he posted it in the PHP forum, let's not forget.
Sep 9 '07 #6

P: 54
How to Add 2 Numbers ?
Here is the code:

<Removed by Admin>
Sep 10 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.