Simple Calculation using static method

Java Programming Language / Class, Object and Methods in java

4492

Program:

 class Calculation{
  static int sqr(int p){
  return p*p;
  }

  public static void main(String args[]){
  int result=Calculation.sqr(5);
  System.out.println(result);
  }
}

/*example of static method that performs normal calculation
*/

Output:

25
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.