- The Java source file extension is. java, which generates a. class file after compilation. All classes have a common inheritance ancestor object class
- There can be only one public class in a. java file, and a public class can only be defined in a file named after its class name
- The Implement keyword is used to implement interfaces, and classes can implement multiple interfaces, inheriting the use of the extends keyword
- Package for better organization of Java programs, packages provide a namespace for Java programs, and the full path of a Java class consists of its package and class name.
- The Java class or no public keyword indicates that the class is visible in the package in which it resides, which is the default access permission in Java
- Package, put the compiled class file under the corresponding path, and then use the import statement to refer to the
- The Super keyword is used to refer to a base class object, in which a class member can be accessed with super, and if the subclass has a function of the same name, the child class member is called when called outside the class
- The basic meaning of the final keyword is that the data/method/class cannot be changed.
Final basic type of data: fixed value (constant value), can only be assigned once and can no longer be modified.
Final method: The method cannot be overwritten. The private method defaults to the final method.
Final class: The class cannot be inherited.
- There is a single inheritance between classes in Java, but multiple interfaces can be inherited
- The abstract,static,string keyword in Java is the same as in C #, as is the function parameter passing rule
- Java refers to the role of pointers, there is a stack but cannot modify the value of the pointer, such as the C language as the pointer + + operation is not allowed, such as Human man = new Human (), the man is a reference to the Human object created in the heap
- Garbage collection: Empty object memory is recycled when no reference is directed to the object
- Exception classes in Java inherit from the Trowable class
- The class class is the abstract of the classes, no matter what kind of conversion we make to the reference, the object itself is the same class object, like the metadata in C #, the role of reflection
- Synchronized is the modifier of the method. In Java, the synchronized method of the same object can be called only by one thread at a time. Other threads must wait for the thread call to end, (the remaining thread one) to run, and synchronized has the same usage as C # lock
- Internal class Rules:
- An inner class can directly access external class members, including private members, in the following notation: external class name. This. External member name
- An external class accesses an inner class, and an inner class object must be established to create an inner class object that must first establish an outer class object
- When an inner class is statically decorated, only static members in the outer class can be accessed
- In the Java generics? Indicates the type is indeterminate, list<?>list
- Runtime exception is the system operation times out of the exception, is the system internal adjustment mechanism reported, such as system memory overflow. Non-runtime exceptions are exceptions caused by improper program writing, the most common null pointer exceptions, array subscripts exceeding exceptions, and so on.
- Throws throws an exception if the exception is an inherited runtimeexception, you do not need to force you to write a try catch statement to ensure that the exception being thrown is handled. If you inherit exception, you will need a try catch statement to ensure that exceptions are handled, and common run-time exceptions are:
- ClassCastException (class conversion exception)
- Indexoutofboundsexception (array out of bounds)
- NullPointerException (null pointer)
- Arraystoreexception (data store exception, type inconsistency when manipulating arrays)
- Import static import is a new feature in JDK1.5. Generally we import a class with import com ..... ClassName, while static import is this: import static com ..... Classname.*, there is more static here, there is a class name ClassName behind more. *, which means to import static methods in this class. Of course, you can just import a static method, just change the. * to a static method name. Then in this class, you can call the static method directly with the method name, rather than using the ClassName. Method name.
Dark Horse Programmer _java Basic Knowledge Summary 3