Introduction to Methods

Let's learn the one important building block of programming: methods (functions).

What is a method?

A method is a small group of reusable code that carries out a single task. To use a method, define the method and call (invoke) the method when needed. Methods can be called an unlimited number of times.

The following is the full syntax for the defined method:

public static int Add2Numbers(int num1, int num2)

Get hands-on with 1400+ tech skills courses.