Java Study Notes

Source: Internet
Author: User

Two thread implementation methods
1. Use the runnable interface
CPU,CodeSeparate from data to form a clear model and inherit from other classes;ProgramStyle consistency.
2. Directly inherit from the Thread class
It cannot be inherited from other classes; it is easy to write and can be directly manipulated without using thread. currentthread ().

Several situations of using method parameters
1. Methods cannot modify parameters of the basic type (numbers or boolean values)
2. The method can change the object parameter status.
3. Methods cannot point an object parameter to a new object.

The source file name must be the same as the public class name. Only one public class can exist in a source file, but it can contain any number of non-public classes.

An important difference between the constructor and other methods is:
The constructor can only be used with the new operator. You cannot apply the constructor to an existing object to reset its instance fields.

The replication constructor allows different objects to have the same data, but points to different objects.

An abstract method can be considered as an outline or convention. It indicates the method that must be implemented by its subclass, but leaves the specific implementation to the subclass.

The arraylist class is more efficient than the Vector class and can be replaced.

You can use one defined in the org. oma. CORBA package to write a method for changing numeric parameters.

Java interfaces should be considered for any use of function pointers in C ++.

The Java event model is strongly typed: events can only be sent to objects that can process them, which is under the monitoring of the compiler.

Java uses Polymorphism or reflection to implement multithreading and callback
C # multithreading and callback using polymorphism, reflection, or delegation

In Java and C #, the memory allocated in the heap is released by the garbage collection mechanism, while the memory allocated in the stack is released after the code block is executed.

We recommend that you do not use both of them when you use AWT or swing for GUI development.
1. Most swing components are lightweight and AWT components are both heavyweight, which may cause disorder of Z-order.
2. It makes swing optimization useless and slows down the speed.

Different from the array index, the column number of the database starts from 1.

The string cannot be changed:
Once a String object is created, the text represented by the string cannot be changed. If you need to modify the characters at any position in the string, you can use Java. Lang. stringbuffer

JDBC's thin and OCI are two sets of Java methods provided by Oracle to access the Oracle database.
Thin is all the methods used to access the database purely in Java. The advantage is that the client does not need to be installed.
OCI uses Java to call the local Oracle client and then access the database. It is fast but requires database installation and configuration.

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.