Java Integer sum() MethodThe sum() method of Java Integer class numerically returns the sum of its arguments specified by a user. This method adds two integers together as per the + operator. It can be overloaded and accepts the arguments in int, double, float and long. Note: If both arguments of the sum() method is in negative, it will always give the result in negative.Syntax:Following is the declaration of sum() method: Parameter:
Returns:The sum() method returns the sum of its method arguments which will be specified by a user. Exceptions:ArithmeticException: It throws exception when the result overflows an integer value. Compatibility Version:Java 1.8 and above Example 1Test it NowOutput: The sum of a and b is = 100 Example 2Output: Enter the Two numbers for addtion: 3435 2865 The sum of a and b is = 6300 Example 3Test it NowOutput: The sum of a and b is = -200 Example 4Output: First Number: 35.55 Second Number: 75.55 The sum of a and b is = 111.10
Next TopictoBinaryString() Method
|