Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
References are a great way to simplify your code. It seems that people just coming to Java get frustrated by various "deficiencies" of the language because all they have really seen of it are the sample programs in a book or two.
It is common in sample code to use the the entire package.class.field naming style to access fields. For primitive types, just copy it to a local variable. For reference fields, why not use a local reference to the class instead? For example, rather than typing this all day long:
// ... System.out.println (something); System.out.println (or); System.out.println (other); // ... System.out.println (yet); System.out.println (still); System.out.println (more); System.out.println (stuff); // ...
Why not just type:
public class SaveTyping
{
private static final PrintStream o = System.out;
// ...
o.println (something);
o.println (or);
o.println (other);
// ...
o.println (yet);
o.println (still);
o.println (more);
o.println (stuff);
// ...
}
That's all there is to it.
Unfortunately, Java does not currently support method references (that is, "method pointers"), so you cannot shorten that part down any further. Well, OK, you could go totally wild and define your own local class, but that is a wee bit over the top in my book, so it is left as an exercise for the reader.
| Subject | Replies |
Last post
|
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq