- It is recommended to put the private method at the end, because our main concern is the public method, which provides external calls.
- Nested classes: other classes are defined within a class. Nested classes allow access to private methods or properties.
- protected is mainly used for inheritance, methods and properties defined as protected can be accessed by its subclasses and subclasses
- 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
- Note that the package name must be exactly the same, the package has no parent-child relationship,
com.apache
andcom.apache.abc
is a different package. - String s = new String (); s.toLowerCase (); // Convert to lowercase letters, s.toUpperCase (); // Convert to uppercase letters;
- 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.
- 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
- 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
-
String s2 = new String(new char[] {'H', 'e', 'l', 'l', 'o', '!'});和String s2 = "Hello!";等价
- To compare whether the contents of a string are equal, you must use the equals () method instead of ==