Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

Get creative with <em>Wicked Cool Java</em>

Peek inside a Java book that presents 101 exciting and cool code bits, open source projects, and project ideas

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Earlier this year, I discovered Wicked Cool Java. Written by Brian D. Eubanks and published by No Starch Press in November 2005, this interesting and helpful book shows Java developers how to get creative with Java by presenting 101 exciting and cool code bits, open source projects, and project ideas. In this article, I present my review of Wicked Cool Java and interview Brian D. Eubanks.

Wicked Cool Java

Wicked Cool Java is not a book for those new to Java. In the introduction, Brian states that he "didn't want to write another 'how-to-program-in-Java' book." Instead, Brian makes it clear that he wanted to write "a book just for the joy of discovering interesting things to do in Java without reinventing the wheel." This book is for those who possess a basic to intermediate level of Java knowledge and are looking for ways to enhance their code.

Wicked Cool Java is organized into eight chapters and an extensive glossary. The first chapter focuses on the Java language and core API. You look at Java 5's new for loop, enums, generics, and variable-arguments language features; you also play with assertions, System.nanoTime(), sub-millisecond thread sleep, and anonymous classes. I especially appreciated the section on equal rights: operator == and the equals() method are not equivalent. Brian's clear discussion of this common pitfall to even experienced Java developers is one of this chapter's jewels. Did you know that the garbage collector thread can remove an interned String value?

Chapter 2 focuses on string processing. This chapter first introduces regular expressions for performing text search, string splitting, text substitution, and more. The Scanner class is next introduced to overcome a limitation with the Matcher class (I won't tell you what that limitation is ... read the book!) Moving on, the topic of generating random text for testing purposes is presented. You next discover Array's deepToString() method for viewing the contents of nested arrays in a meaningful way—a method I was previously unaware of.

The next topic begins one of this book's major themes: introducing Java developers to open source projects that save them from "reinventing the wheel." You discover two classes in Apache's Jakarta Commons Codec project for converting between binary data and hexadecimal or Base64, which is part of the Multipurpose Internet Mail Extensions (commonly referred to as MIME) for representing binary data in a human-readable format. Chapter 2 concludes with a discussion on using MessageFormat and System.out.format() to format data.

At some point in your Java career, you'll need to process well-formed HTML and XML documents. After providing a quick XML refresher, Chapter 3 shows you how to parse XML documents via Java's built-in SAX (Simple API for XML) parser and the open source DOM4J Document Object Model (DOM) parser. Did you know that DOM4J supports XPath? That expression language lets you conveniently traverse a DOM4J tree, and this book shows you how to do just that. You next learn about JavaCC, the open source parser generator for creating parsers based on your own grammars, and look at converting these grammars into XML. I really enjoyed the chapter's discussions on using Java Database Connectivity's WebRowSet interface and its implementation class for converting database query ResultSets to XML, screen-scraping data from HTML pages, and working with the open source Lucene API to add sophisticated search logic to applications.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources