Professional Documents
Culture Documents
0 Java Language
4.5 Method
4.5.3 Static User-defined Method
Learning Outcomes :
(1 Hour)
METHOD
METHOD
❖ Built in method in Java that are readily ❖ Methods define by the programmer
available for use
❖ Example :
➢ next() – defined in Scanner class
➢ sqrt () – define in Math class
➢ pow () – define in Math class
➢ print () – define in java.io.PrintStream
❖ Built in method in Java that are readily ❖ Methods define by the programmer
available for use
❖ Example :
➢ next() – defined in Scanner class
➢ sqrt () – define in Math class Static Method Non-Static Method
➢ pow () – define in Math class NOT IN YOUR SYLLABUS
➢ print () – define in java.io.PrintStream
❖ Built in method in Java that are readily ❖ Methods define by the programmer
available for use
❖ Example :
➢ next() – defined in Scanner class
➢ sqrt () – define in Math class Static Method Non-Static Method
➢ pow () – define in Math class NOT IN YOUR SYLLABUS
➢ print () – define in java.io.PrintStream
❑ Not require an object ❑ Require an object to
to call the method call the method
* Programmers like you can just use
them without learning their method
definition
METHOD
multiply(10,5);
multiply(100,5);
multiply(100,50);
multiply(9,50);
}//end of main
• User-defined methods must be defined inside a class, and outside main() method.
Based on previous example : 2 terms that you have to know
Calculate and display the multiplication of a and b, c and d, e and f, and h and g.
(Given the value of a = 10, b =5, c = 100, d = 5, e = 100, f = 50, g = 9, h =50)
multiply(10,5);
multiply(100,5);
1. Method Calls
multiply(100,50);
multiply(9,50);
}//end of main
• User-defined methods must be defined inside a class, and outside main() method.
Based on previous example : 2 terms that you have to know
Calculate and display the multiplication of a and b, c and d, e and f, and h and g.
(Given the value of a = 10, b =5, c = 100, d = 5, e = 100, f = 50, g = 9, h =50)
multiply(10,5);
multiply(100,5);
1. Method Calls
multiply(100,50);
multiply(9,50);
}//end of main
}//end of class
Based on previous example : 2 terms that you have to know
Calculate and display the multiplication of a and b, c and d, e and f, and h and g.
(Given the value of a = 10, b =5, c = 100, d = 5, e = 100, f = 50, g = 9, h =50)
multiply(10,5);
multiply(100,5); 1. Method Calls
multiply(100,50);
multiply(9,50);
}//end of main
}//end of class
• User-defined methods must be defined inside a class, and outside main() method.