Java Foundation Five

Source: Internet
Author: User
1 Method 1.1 Method Overview
  • Suppose there is a game program in which the program is constantly firing shells (plants vs. Zombies) during operation. Firing shells requires 100 lines of code to be written, and each time a projectile is implemented, the 100 lines of code need to be written repeatedly, so the program becomes bloated and poorly readable. In order to solve the problem of code duplication, you can extract the code of the firing shells into a {}, and give the code a name, so that the name of each firing cannon to invoke the code of the firing shells.
  • In the above procedure, the extracted code can be considered as a method (or function) defined in the program, and the program can call the method directly when it needs to fire the shells.

2 arrays

Java Foundation Five

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.