From the course: Java 8+ Essential Training: Objects and APIs

Unlock the full course today

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

Wrap code in static methods

Wrap code in static methods - Java Tutorial

From the course: Java 8+ Essential Training: Objects and APIs

Start my 1-month free trial

Wrap code in static methods

- [Instructor] Most programming languages let you create reusable code, code blocks that you can call from multiple places in an application. These are sometimes called functions or subroutines in other languages, but in Java they're called methods, and they're always declared as members of a class. Each method starts with one or more declarations. The methods return type is required. The main method that starts up a command line application has a return type of void, meaning that it doesn't return anything. This is something that might be called a subroutine in other languages, but it's simply called a method in Java. The keyword public is an access modifier. It determines the visibility of this method to the rest of the application. The public access modifier means it can be called from anywhere. Other access modifiers include private and protected, and the absence of an access modifier has its own meaning. Static means that this method can be called directly from the class without…

Contents