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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashok244992
    New Member
    • Sep 2007
    • 2

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

    How to Add 2 Numbers ?
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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.

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      ...with the '+' operator?

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Ganon11
        ...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 'ClassCastExcep tions' 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

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          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.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            ... and that he posted it in the PHP forum, let's not forget.

            Comment

            • ramadeviirrigireddy
              New Member
              • Jul 2007
              • 54

              #7
              Originally posted by ashok244992
              How to Add 2 Numbers ?
              Here is the code:

              <Removed by Admin>
              Last edited by r035198x; Sep 10 '07, 08:14 AM. Reason: Spoon feeding or attempted spoon feeding is against site rules

              Comment

              Working...