JDK 1.6.x (1.6.0 _ 16) and earlier versions

Source: Internet
Author: User

Recently, you need to organize a previous project and add new interfaces. This project went on for a long time. We started to use the jdk1.4 version and later the jdk1.5 version. Later, I found a bug in JDK (I forgot about it, but I haven't found the document yet, as if it was related to time). I need JDK. There is no problem from 1.4 to 1.5. from 1.5 to 1.6, there is no problem in source code, but 1.6 compilation cannot run on jre1.5.

Then these things began to be dusty. One year later, during this period, the lab was moved, the machines were changed, and the original development environment was gone. Some documents need to be searched slowly, starting with source code. I downloaded the latest jdk1.6.16. As soon as compilation is complete, it's just dizzy. One year later, Java has become like this ......

More Object: int and Integer

Java emphasizes objects more. In earlier versions, integer values can be assigned to int values. Currently, Java strictly distinguishes these two concepts. If int is assigned to integer, you must use integer. valuleof (I ). To convert a character to an integer, you must use integer. parse () to cancel integer. Decode (). In the new version, it is no longer allowed between int and integer, and between double and double ...... as an equivalent, for example, assigning a value directly through "=" or using it in method parameter transfer, it clearly divides the integer/floating point type and object originating in C.

Entry type of Vector

In versions earlier than 1.5, including versions earlier than 1.6, the vector type is defined in new, for example, new vector <mytype> (), and private vector <mytype> myparam; if you do not enter <mytype>, a warning is reported. However, in the latest version, specifying the type is not allowed during creation. Even if <mytype> is allowed, it is similar to hashtable, stack, and enumeration.

String. format: discard the va_list method of C.

The worst is String. format (). Originally, This method uses sprintf similar to C. You can enter any parameter and assign a value to a String according to the specified format. For example, string0 = String. format ("% 2.4f OK", f); this is a flexible and convenient writing method. It is used a lot in projects, but this method is not allowed in the new JDK. Report:

The method format (String, Object []) in the type String is not applicable for the arguments (String, Double)

To be written in the format of (String, Object []), that is, the preceding example should be written:

String0 = String. format ("% 2.4f", new Object [] {Double. value (f )});

If multiple parameters are listed in new Object [] {obj1, obj2. For the types integrated with C such as int, double, float, and so on, we can participate in computing in the new JDK. However, we recommend that you do not use Integer as a class parameter. If possible, try to use Integer, double, Float class.

For the Long type, note that, unlike C, JAVA does not support % ld. You can use % d or % s.

I think the new method of String. format is very inconvenient to use and the code looks not elegant. However, JAVA can be used to discard the method of va_list C and further object-oriented. All is object.

Hashtable: key revision

Unlike the Writing Method for modifying the data type such as Vector, Hashtable modifies the key usage mode. Previously, we needed to directly give hashcode, put, get, and remove through hashcode. In the current version, use obj directly,
To successfully store and retrieve objects from a hashtable,
Objects used as keys must implementhashCode
Method andequals
Method. For example, we used to add an entry as follows: db. put (name. hashCode (), entry), where name is String. Now we need to write it as db. put (name, entry ).

Changes in the format () method parameters of SimpleDateFormat

This is also a common parameter in the project. If we have records involving CDRS or calleg, this is a very simple method. We used dformat. format (long t), such as dformat. format (System. currentTimeMillis (), but dformat is required in the new version. format (Date d), which must be written as dformat. format (new Date (System. currentTimeMillis ()))

After the acquisition of NOKIA, QT became free, and JAVA, which was initially launched with the free flag, was divided into free and paid versions after Oracle's acquisition. Like the openness of Andriod and the closure of apple, they all live very well. The two opposite directions are not right or wrong, and the concept of this dual theory is indeed liked by many people. We have accepted many similar ideas since childhood. For example, a bad guy in a movie, including a bad guy or a bad guy. When I was in junior high school, the political book regarded the planned economy as orthodox, and refuted the market economy. When I went to high school, I turned to the market economy as a guideline and criticized the planned economy, this is the same time. We don't believe it, but we don't know what to believe.

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.