Typesafe Enums, Autoboxing, ... (JSR 201)

View: [ 2009 | 2008 | 2007 | 2006 | 2005 | 2004 | 2003 ]

Articles
Tips
  

Articles:
  • Enhance looping in Java 5.0 with for/in by Brett McLaughlin   - [Clicks: 18]
    The for/in loop -- often called either enhanced for or foreach is largely a convenience feature in Java 5.0. It doesn't really offer any new functionality, but certainly makes several routine coding tasks simpler. In this article, you'll learn about many of those, including using for/in to iterator over arrays and collections, as well as how it can help avoid unnecessary (or just plain annoying) typecasts. You'll also learn how for/in is implemented, glean details about the new Iterable interface, and even understand how to make your own custom objects usable with this new construct. Finally, you'll learn about the things that for/in can't do to make sure you understand when plain old for is the right choice.
    http://www-106.ibm.com/developerworks/java/library/j-forin.html - Nov, 2004
  • Getting started with enumerated types by Brett McLaughlin   - [Clicks: 50]
    One of the great new features in Tiger is the enumeration construct, a new type that allows you to represent specific pieces of data as constants, all in a type-safe manner. Tiger expert and frequent developerWorks contributor Brett McLaughlin explains what an enumeration is, how you can use it in your programs, and why it will allow you to dump all that old public static final code.
    http://www-106.ibm.com/developerworks/java/library/j-enums.html - Nov, 2004
  • J2SE 5.0 Static Imports: To Use or Not to Use? by Chakra Yadavalli   - [Clicks: 17]
    To use or not to use? That is the question. Or if they are to be used, then how? In this article, Chakra Yadavalli looks first at what static import is, explores how it might help us write code shorter, faster, and cleaner; then examines how the development tools could help us to "code at the speed of thought" - without compromising the comprehensibility or maintainability of the code.
    http://www.sys-con.com/story/?storyid=46281&DE=1 - Sep, 2004
  • Creating Varargs in Java 1.5 Tiger by David Flanagan, Brett McLaughlin   - [Clicks: 18]
    In this excerpt from Chapter 5 of the book, Brett and David cover how to create and iterate over variable-length argument lists (better known as varargs), which will have you writing better, cleaner, more flexible code in no time.
    [O'Reilly Book Excerpts: Java 1.5 Tiger: A Developer's Notebook]
    http://www.onjava.com/pub/a/onjava/excerpt/javaadn_chap5/index.html - Aug, 2004
  • Using For Loops in J2SE 1.5 by Jeff Langr   - [Clicks: 13]
    Gain simplicity in your J2SE 1.5 source code by utilizing For Loops.
    http://www.developer.com/java/other/article.php/3343771 - Apr, 2004
  • Java Tech: Using Variable Arguments by Jeff Friesen   - [Clicks: 15]
    Speaking of Tiger (also known as J2SE 1.5), this article focuses on the new variable arguments language feature. After examining basic syntax, we'll cover diverse uses for variable arguments.
    http://today.java.net/pub/a/today/2004/04/19/varargs.html - Apr, 2004

[Top]

Tips:
  • Using Static Imports for Constants and Methods by Daniel H. Steinberg   - [Clicks: 11]
    Many new language features have been introduced in the release of J2SE 5.0. Static imports is a feature that helps in the creation and use of global constants. It's one of the easiest new features to incorporate into your code. In this tip, you'll have the chance to use static imports for constants and methods. You'll start with the traditional technique of using "constant interfaces". These interfaces only exist to hold constants. These constants should be moved into utility classes, but these classes have traditionally been hard to use. The problems disappear with static imports. In addition to their use for constants, static imports can ease the calling of methods and classes. However there is a downside to using static imports in this way: it can make your code less readable. This is especially true with wild cards. It can become hard to determine where methods and attributes originate.
    http://java.sun.com/developer/JDCTechTips/2004/tt1005.html#1 - Oct, 2004

[Top]