# Calculate the Sum of three Numbers

This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three static variables.

Ads

Tutorials
Ads

# Calculate the Sum of Three Numbers

This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three static variables.

Description of this program:

In this section we will see how to calculate three integer number . First of all define class name "StaticSum". For this we have defined three static variables of type int.  To assign the value of the numbers define a method main. Remember we are overloading the main method. This method will take three arguments.  The values will be added in the Addition method which we have declared in our program. Now call the main method. To get the values of the three numbers call the overloaded method main() inside main() method. To add those values call the Addition method which will return the integer value and the value will be displayed to the user by using the println() method of the System class.

Here is the code of this program

 ``` class StaticSum  {   public static int width;   public static int height;   public static int length;   public static void main(int width1, int height1, int length1)    {   width= width1;   height=height1;   length=length1;   }   public int Addition()   {   return(width+height+length);   }   public static void main(String arg[])   {   StaticSum staticSum = new StaticSum();   StaticSum.main(12,14,15);   int i= staticSum.Addition();   System.out.println("value is="+ i);   } }```

`Download this Example`

Advertisements

Online Training Classes

Share on Google+

# Calculate the Sum of three Numbers

Posted on: June 25, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads

Related Tutorials

Discuss: Calculate the Sum of three Numbers   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):

Comments:0

Ads

Ads