[J2se 1.5] Eight Poems by Joshua Bloch and tiger

Source: Internet
Author: User
Eight Poems by Joshua Bloch and tiger

"Degree of development" is the main selling point of j2se 1.5. Therefore, this version includes seven new language features: enhanced for loop, autoboxing/auto-unboxing, varargs, static import, enumeration, metadata, and generics. By using these features, you can make the compiled programs more concise, clearer, and error-prone, thus simplifying the development process.

Joshua BLOCH (author of objective Java, one of the main developers of j2se 1.5) imitates William Blake (1757-1827, British poet)'s tiger poem, I wrote a group of poems for these features:

Yong Tiger

Tiger, Tiger burning bright
Like a geek who works all night
What new-fangled bit or byte
Cocould encrypt the hacker's weary plight?

This article describes various new language features that make development simple in tiger.

Yong enhanced for Loop

While Iterators have their uses
They sometimes strangle us like nooses
With enhanced-for's deadly ray
Iterator's kept at bay

This single-Table enhanced for Loop Mechanism provides a simpler way to traverse arrays, collections, and other objects that implement the java. Lang. iterable interface.

Yong autoboxing/auto-unboxing

When from the collections ints are drawn
Wrapper classes make us mourn
When Tiger comes, we'll shed no tears
We'll autobox them in the ears

This single table autoboxing mechanism/auto-unboxing provides a simpler mechanism for integrating two different types of systems (Basic Types and reference types.

Yong varargs

O joyless nights, O joyless days
Our programs cluttered with Arrays
With varargs here, We needn' t whine;
We'll simply put the ARGs inline

This single table varargs Mechanism provides a simpler way to pass real parameters with variable numbers.

Yong static Import

And from the constant interface
We shall inherit no disgrace
With static import at our side
Our joy will be unqualified

This single-Table Static Import mechanism provides a simpler mechanism for accessing Static members.

Yong Enumeration

The Int-Enum will soon be gone
Like a foe we 've known too long.
With type safe-Enum's mighty power
Our foe will bother us no more

This single-Table Enumeration Mechanism provides a simpler method for defining "type-safe Enumeration classes.

Yong metadata

As for noble metadata
I'll have to sing its praises later
Its uses are so numerous
To give their due, I 'd miss the bus

This single table Metadata Mechanism provides a simpler mechanism for defining "machine-readable description information.

Yong generics

To the most despised collections 'Cast
We'll bid a fond farewell at last
With generics 'Burning spear
The need for cast will disappear

This article describes how to use the Generics mechanism to avoid many steps of forced type conversion. The Generics mechanism has some other usage, which is not mentioned here.

Complexity of various features

The complexity of the seven new language features in J2SE 1.5 is inconsistent. In general, Enhanced for Loop, Autoboxing/Auto-Unboxing, Varargs, and Static Import are relatively simple, while Enumeration, Metadata, and Generics are relatively complex.

A feature not included

J2SE 1.5 does not include all the invented language features that can simplify development-for example, the function of assigning default values to parameters is not included. Of course, if you only want to achieve this effect, you can consider using overload instead.

Related content
  • Gradually mine enhanced for Loop
  • Gradually mine autoboxing/auto-unboxing
  • Gradually mining varargs
  • Gradually mine static Import
References
  • Joshua Bloch's poems are taken from Qusay H. Mahmoud's "the all-new Java 2 platform, Standard Edition (j2se) 1.5 platform:
    Programming with the new language features in j2se 1.5.
  • For more information about "type-safe enumeration classes", refer to Chapter substitutes for c constructs in Joshua Bloch's "Effective Java.

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.