More about static methods

  1. Recall that:

  2. Defining static method:

    Example: computing the cube of a number
          public class Numeric // You have to put it in some class...
          {
    	 public static double cube(double x)
    	 {
    	    return( x*x*x );
    	 }
          }
    
    

  3. Using the static method that you have just defined:

    Example:
          public class TestNumeric
          {
    	 public static void main(String args[])
    	 {
    	    double r = 0.9;
    	    double r3;
    
    	    r3 = Numeric.cube(r); 
    	 }
          }
    
    

  4. NOTE: