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