Home arrow Java arrow Page 5 - What`s New in Java 1.5 Tiger?
JAVA

What`s New in Java 1.5 Tiger?


Call it Java 1.5, 2.0, Java 5, Tiger, or what have you -- this version of Java has a lot to offer. This article covers just some of the new features. It is excerpted from chapter one of Java 1.5 Tiger: A Developer's Notebook, written by Brett McLaughlin and David Flanagan (O'Reilly, 2004; ISBN: 0596007388).

Author Info:
By: O'Reilly Media
Rating: 4 stars4 stars4 stars4 stars4 stars / 13
May 19, 2005
TABLE OF CONTENTS:
  1. · What`s New in Java 1.5 Tiger?
  2. · Using Queues
  3. · Ordering Queues Using Comparators
  4. · Overriding Return Types
  5. · Taking Advantage of Better Unicode
  6. · Adding StringBuilder to the Mix

print this article
SEARCH DEVARTICLES

What`s New in Java 1.5 Tiger? - Taking Advantage of Better Unicode
(Page 5 of 6 )

While many of the features in this chapter and the rest of the book focus on entirely new features, there are occasions where Tiger has simply evolved. The most significant of these is Unicode support. In pre-Tiger versions of Java, Unicode 3.0 was supported, and all of these Unicode characters fit into 16 bits (and therefore a char). Things are different, now, so youíll need to understand a bit more.

How do I do that?

In Tiger, Java has moved to support Unicode 4.0, which defines several  characters that donít fit into 16 bits. This means that they wonít fit into a char acters inchar, and that has some far-reaching consequences. Youíll have to use  int to represent these characters, and as a result methods like  Character.isUpperCase() and Character.isWhitespace() now have variants that accept int arguments. So if youíre needing values in Unicode 3.0 that are not available in Unicode 3.0, youíll need to use these new methods..

What just happened?

To really grasp all this, you have to understand a few basic terms:

codepoint

A codepoint is a number that represents a specific character. As an example, 0x3C0 is the codepoint for the symbol π.

Basic Multilingual Plan (BMP)

The BMP is all Unicode codepoints from \u0000 through \uFFFF. All of these codepoints fit into a Java char.

supplementary characters

These are the Unicode codepoints that fall outside of the BMP. There are 21-bit codepoints, with hex values from 010000 through 10FFFF, and must be represented by an int.

A char, then, represents a BMP Unicode codepoint. To get all the supplementary characters in addition to the BMP, you need to use an int. Of course, only the lowest 21 bits are used, as thatís all that is needed; the upper 21 bits are zeroed out.

All this assumes that youíre dealing with these characters in isolation, though, and thatís hardly the only use-case. More often, youíve got to use these characters within the context of a larger String. In those situations, an int doesnít fit, and instead two char values are encoded, and called a surrogate pair when linked like this. The first char is from the high-surrogates range (\uD800-\uDBFF), and the second char is from the low-surrogates range (\uDC00-\uDFFF). The net effect is that the number of chars in a String is not guaranteed to be the number of codepoints. Sometimes two chars represent a single codepoint (Unicode 4.0), and sometimes they represent two codepoints (Unicode 3.0).


blog comments powered by Disqus
JAVA ARTICLES

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials