课程: Java Essential Training: Syntax and Structure
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Creating methods
- [Instructor] In Java, methods are subtasks within a class that are used to break a complex problem into small manageable pieces. Methods perform a specific task and can help eliminate redundancy and code. Other programming languages have different names for these such as functions or modules. But in Java, they're known as methods. We've already created one method in every program that we've written so far. And that's the main method. We've also made calls to other methods, such as the ones in the scanner class to input data and the ones in the system class to output data. This is a method whose task is to calculate two numbers and return a sum. Let's examine the parts of a method. The very first line of the method is called the header. The first word in a method header is the access modifier. Access modifiers indicate who is allowed access to use this method. Public means any code from any class can use this method.…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。