From the course: Learning Java 17

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Calling functions in Java

Calling functions in Java - Java Tutorial

From the course: Learning Java 17

Calling functions in Java

- [Instructor] Now that we've defined our announceTeaTime function, we can proceed to the next step, using functions in Java. To use a function, we just call it by name. We often refer to this as calling the function. We're recalling the steps we defined previously and we're executing them. Let's call this function in Java. We defined our function outside of the main function, but we're going to use our function inside the main function. We'll use it by name, announceTeatime. This will call the announceTeatime function, execute its steps, and then continue to execute whatever's left in the main function sequentially. Let's run this in debug mode so we can see what's happening. We'll add a break point to where we call the function and then run it. The program's execution has just started and we're about to call the announceTeatime function. Notice we have no variables in our variables window, which means no variables are…

Contents