Java Notes [Continuously updated ...]

 

  1. It is recommended to put the private method at the end, because our main concern is the public method, which provides external calls.
  2. Nested classes: other classes are defined within a class. Nested classes allow access to private methods or properties.
  3. protected is mainly used for inheritance, methods and properties defined as protected can be accessed by its subclasses and subclasses
  4. There is no public, protected, private modified class or method or attribute, the default is the scope of the package scope, limited to access in this package
  5. Note that the package name must be exactly the same, the package has no parent-child relationship, com.apacheand com.apache.abcis a different package.
  6. String s = new String (); s.toLowerCase (); // Convert to lowercase letters, s.toUpperCase (); // Convert to uppercase letters;
  7. When using local variables, the scope of local variables should be reduced as much as possible, and local variables should be deferred as much as possible.
  8. The final modifier does not conflict with access rights: the class decorated with final cannot be inherited, the method of final modification cannot be rewritten, and the property of final modification cannot be changed once assigned, which is a constant
  9. A .java file can only contain one public class, and the class name must be the same as the file name. But can contain multiple non-public classes
  10. String s2 = new String(new char[] {'H', 'e', 'l', 'l', 'o', '!'});和String s2 = "Hello!";等价
  11. To compare whether the contents of a string are equal, you must use the equals () method instead of ==

Guess you like

Origin www.cnblogs.com/gslgb/p/12697961.html