Java Basics Note (i: modifiers, vectors, hash tables)

Source: Internet
Author: User
Tags modifier modifiers

One, the characteristics of the Java language (develop The habit of frequently viewing the Java online Help document)

(1) Simplicity:the Java language is in C and C + + A new computer language that simplifies and improves on the basis of computer language. It removes the most difficult pointers for proper application of C and C + + and the most difficult to understand multiple inheritance technologies, and simplifies program memory management through garbage collection mechanism. Unifies the amount of memory used by various data types on different operating system platforms.

(2) network characteristics:Java language is currently the most comprehensive network support, and the network is one of the most closely related computer language.

(3) Object-oriented: Because the Java language is a new type of computer language, there is no burden of compatible process-based computer language, so java Language is more thorough than the C + + language in object-oriented features .

(4) platform-agnostic / portability:theJava language is designed to allow programs to run on any computer platform without modification.

(5) Stability:Java in the compilation and execution of the process will be more rigorous checks to reduce the occurrence of errors. The garbage automatic recovery mechanism and exception handling mechanism of Java language improve the stability of the program to a great extent. In addition,the simplicity of theJava language also improves the stability of the program to some extent.

(6) Security: Java programs running on the network are compliant with the network security protocol. during the execution of a Java program,theJava Virtual machine detects the security of the program.

(7) Multithreading: This is primarily used to handle complex transactions or transactions that require parallelism. The various programs that make up a Java virtual machine generally also employ multithreading mechanisms. The multi-threading mechanism is a method to improve the efficiency of the program, but it also increases the design difficulty of the program.

(8) Explanatory:theJava language is an explanatory language. This is a disadvantage of the Java language because the language of the interpretation is generally less efficient than the language in which it was compiled (for example,C or C + +).

Second, the role of the environment variable path and classpath

Run path ( path) variable records the path where each running program is located. The system looks for the running program based on the value of the variable.

The Classpath (classpath) is typically used to record The path where the current path and J2SE class library are located, which is An environment variable that J2SE requires.

in the The J2SE class library contains Various packages provided by the J2SE system, including classes and interfaces. After you set the Classpath (classpath) environment variable, you can use the current path and the various Java under the path of the J2SE class library directly in your program the class or interface of the software package.

abstract,staticandfinal description of the modifier words

  ( 1) abstract (abstract): java allows classes, interfaces, or member methods to have abstract properties, but does not allow member fields or constructor methods to have abstract properties. If the keyword abstract abstract abstract

The difference between the definition format of an abstract member method and the defined format of a member method that does not have an abstract attribute is that the definition of the abstract member method ends with no method body, except that it contains the method modifier abstract. The definition of a member method that does not have an abstract attribute cannot appear immediately after a member method declaration, and must contain a method body.

(2)static: Classes generally cannot have static properties other than the inner class. The constructor method of a class cannot have a static property. The member fields and member methods of a class can have static properties. If you add a modifier static to the list of domain modifiers that define a member field , the member field has a static property. If you add a modifier static to the list of method modifiers that define a member method ,the member method has a static property, called a static member method.

in the In the Java language, a class is a template for its instance objects, and the class itself can be considered an object, referred to as a class object. The static members of the class are subordinate to the object. You can access the static member domain of a class or invoke a static member method of a class directly from the class name. The exact form is as follows: Class name . Static member field, class name . static Member Method name (member method invocation parameter list).

(3)final(final): the keyword final(final) can be used to decorate classes that do not have abstract properties, member fields of classes, The member fields of the interface and the member methods of the class that do not have an abstract attribute. If a class-modifier final is included in a list of modifiers that define a class , the class is said to have a final attribute.

If you add a modifier final to the list of modifiers that define a member field , the member field is said to have a final attribute. If the member domain has both final and static properties, the member field can only be assigned when defined, and after that, the value of the member field cannot be modified. If the member field has a final property, but does not have a static property, the member field can be assigned only at the time of definition, or in a constructor method, and can only be assigned once.

If you add a modifier final to the list of method modifiers that define a member method , the member method is said to have a final attribute. At this point, the member method is required to have no abstract properties. If a member method of a class has a final attribute, the member method cannot be overridden by a member method of the subclass of the current class.

iv. introduction of vectors

A vector is functionally similar to an array, except that the number of its elements can be changed, and the data type of the vector element must be a reference type. The basic principle of vectors is to assign a certain amount of storage space to a vector object beforehand, and then add elements or set element values to the vector object. The size of the vector object's storage space is called the capacity of the Vector object, and its units are the number of elements. The number of actual elements of the vector object, called the length of the vector object. If the length of the vector object changes, the capacity of the vector object expands automatically when the new length exceeds the old capacity of the vector object before the length changes. There is also a quantity defined in the Vector object, called the capacity increment.

the declaration format for a vector variable is: vector< The data type > variable name of the vector element;

How to create a vector instance object: typically , a vector object is created by constructing aclass Java.util.Vector-the publicvector () can create a vector object whose initial capacity default value is The capacity increment is the default value of 0.

the operation of the Vector object instance object mainly has an increment element (the member method hasAdd,addelement,insertelementand Modify elements (member methods haveSet,setElement), delete element (member method hasClear,Remove,removeelement,removeelement), information query (member methods arecontains,equals,capacity, etc.).

Five Introduction to Hash table

arrays and vectors store elements sequentially, so the element can be easily obtained by the subscript of the element. Conversely, if you know an element and want to get the subscript for that element, it is relatively difficult, and it is often necessary to find it sequentially. If an array or vector is already sorted in a certain way, you can use the dichotomy method to find binary, speeding up the discovery process. It is generally assumed that the fastest way to find the storage location for this element from an element is to use a hash table. Hash tables are also known as hash lists.

Hash Table Detailed Links:http://www.cnblogs.com/vamei/archive/2013/03/24/2970339.html#undefined

Java Basics Note (i: modifiers, vectors, hash tables)

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.