Java Learning Note 2

Source: Internet
Author: User

1  PackageWelcome;2 3  Public classConstants {4      Public Static voidMain (string[] args) {5         Final DoubleCm_per_inch = 2.54;//final indicates that the variable can only be assigned once and once it has been assigned, it can no longer change the value of the6         DoublePaperWidth = 8.5;7         DoublePaperheight = 11;8System.out.println ("Paper in centimeters:"9+ paperwidth * cm_per_inch + "by" + paperheight *cm_per_inch);Ten     } One}

1  PackageWelcome;2 3  Public classConstants2 {4     //set a class constant so that each method of the same class can be used. If a constant is declared public, the methods of other classes can also use this constant5      Public Static Final DoubleCm_per_inch = 2.54; 6     7      Public Static voidMain (string[] args) {8         DoublePaperWidth = 8.5;9         DoublePaperheight = 11;Ten          OneSystem.out.println ("Paper in centimeters:" A+ paperwidth * cm_per_inch + "by" + paperheight *cm_per_inch); -     } -}

Self-increment (decrement) operator:

The square root of a negative number is a Nan

Encapsulation: Hides the hidden, public
A class is a small module.
When programming, should try to avoid a module directly operate and access to another module of data, module design pursuit of high cohesion (as far as possible the internal data of the module, the implementation of the details of the function hidden within the module independent completion, not allow external direct intervention), low coupling (only exposed a small amount of methods for external use)

Java Learning Note 2

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.