From the course: Java 11+ Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create reusable code with methods

Create reusable code with methods - Java Tutorial

From the course: Java 11+ Essential Training

Start my 1-month free trial

Create reusable code with methods

- [Narrator] Most programming languages support the ability to create reusable code: Code blocks that you can call from multiple places in an application. These are sometimes called functions, or subroutines. In Java, they're called methods, and they're always declared as members of a class. The main method is one example, every method requires a signature, including the method's name, the type of data it returns, and declarations of any parameters the method receives. The main method has a required signature in console applications, the name has to be main, all lower case. It has to return void, which means, "nothing," and it has to be static, which means that it can be called from the main class, without having to create an instance of the class. It also has to receive a parameter, that's an array of strings. Notated like this. The name of the parameter doesn't matter, it can be anything. But the type is required.…

Contents