课程: Java 8+ Essential Training: Objects and APIs

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Wrap code in static methods

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…

内容