JDK1.5 usage summary -- Java 1.5 Tiger: A Developers Noteboo

Source: Internet
Author: User
JDK 1.5.1 is a Debug version.
I feel that the most important revolution of JDK1.5 is Annotations, while the rest, such as Generics, Concurrency, and JVM Tools, may be important weapons for some opensources, however, we do not have any feelings for such a small dipper. The rest is a small change.
I read Java 1.5 Tiger: A Developer's Notebook again. Combined with the previous applications, I summarized the following useful new features: 0. the most important function of Annotations is, I believe, to break the language revolution weapon of traditional C/C ++ fenders together with AOP. In contrast, dynamic language simplifies the amount of code without making a breakthrough in programming architecture.
1. AutoBoxing: this is the only new feature that makes small citizens feel. In the end, there is no need to explicitly convert Integer and int values, but this is a natural thing.
2. Generics feels like adding a strong lock to all the container classes. In a world where dynamic languages such as Python are popular, strong types seem less appealing.
The advantage of Generics is that Type is Safe and does not need to be converted during the loop. Otherwise, type definitions must be added to all definitions and declarations to increase the total amount of code. If you use the old loop syntax, even Iterator must declare the type.
Alternatively, you can try to write your own generic classes, which may be helpful for some Open Source Util classes, but your own business classes will only be unsolvable in OO, to be used. For example, public class Box {private List contents;} 3. The for/in statement replaces interator. Except for several basic types, you must declare Collection with generics.
4. enumeration enumeration can replace the previous public static final a = 1; public static final B = 2; it can also replace the less disciplined String "", "B" and int 2nd replace the advantages of cases. Statifc final a = 1 because it still cannot limit programmers to be lazy and use int directly, so they lose and enum. In addition, enum has less code and can be used for other extensions.
1. base public enum Grade {A, B, C}; Grade. a. toString () = "A"; Grade. valueOf ("A") returns Grade. a; the toString () method can be reloaded, but the valueOf () method needs to be reloaded at the same time. 2. generally, enumeration is defined by inline, and seldom occupies a class file. public class Downloader {public static enum DownloadStatus {INITIALIZING, IN_PROGRESS, COMPLETE};} 3. traverse Grade [] gradeValues = Grade. values (); for (Grade g: Grade. values () {out. pring (g);} 4. enumMap ()/EnumSet () antMessages. put ( NtStatus. ERROR, "Error occurred. "); 5. expansion complexity is not detailed yet. static import simplifies the use of tool classes, such as StrUtil. isEmpty () can be written as isEmpty (), and only the specified function can be imported. In addition, you can also statically import Enum, such as Status. A can be written as A, but it also causes fuzzy reading.

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.