Skip to main content

Posts

Showing posts with the label java

Java EE 6 one-week Online Codecamp

Javapassion.com is conducting a week long codecamp for Java EE6, starting Jan 12. The course is conducted online, and details are available here . Among other things, it covers Java EE6, GlassFish v3, JSF 2.0, EJB 3.1 and Servlet 3.0. The course sessions are scheduled between Jan 12 and Jan 20. If you finish and submit all the homeworks, you receive a certificate. via

Reference Guide: HProf

InformIT has published a user guide to HProf, the Java profiling tool from Sun. Sun includes a profiling tool built into the JVM called HProf that can provide you with method-level response times as well as heap information. The JVM provide various programmatic interfaces that allow you to obtain runtime information, and as of Java 5.0 SE, the newest and least invasive is the Java Virtual Machine Tool Interface(JVMTI), which HProf is based on. HProf can be invoked by providing a command line option when you start your Java application and then it generates a log file as output, which you can either examine manually or programmatically parse. Furthermore, HProf executions can be integrated into a build script in order to generate reports automatically. http://www.informit.com/guides/printerfriendly.aspx?g=java&seqNum=363

New Features in Java 5

Several useful features have been introduced in Java 5. Generics : A way to make classes type-safe that can work on any type, such as narrowing an instance of a collection to hold a specific object type and eliminating the need to cast objects when taking an object out of the collection. Enhanced for loop : A cleaner and less error-prone version of the for loop for use with iterators. Variable arguments : Support for passing an arbitrary number of parameters to a method. Boxing/unboxing : Direct language support for automatic conversion between primitive types and their reference types (such as int and Integer). Type-safe enumerations : Clean syntax for defining and using enumerations, supported at the language level. Static import : Ability to access static members from a class without need to qualify them with a class name. Metadata : Coupled with new tools developed by third-party companies, saves developers the effort of writing boilerplate code by automatically generating the code...

Java 5 Feature: An intro to foreach

Looping is a control structure that has been around ever since we started programming. The good old syntax for looping that you would have used most often is: String[] messages = {"Hello", "Greetings", "Thanks"}; var length = messages.length; var int i = 0; for(i = 0; i System.out.println(messages[i]); } What if you want to iterate over a collection, like ArrayList? We will do something like: Iterator iter = lst.iterator(); for(;iter.hasNext();) { System.out.println(iter.next()); } The foreach was introduced to avoid introduction of any new keywords. The foreach introduced in Java 5 simplifies looping further. Let’s take a look at an example of how we can use the new way to loop: for (String msg : messages) { System.out.println(msg); } You would read for (String msg : messages) as "foreach String msg in messages". Within the loop of foreach, msg represents a String element within the array String[]. Instead of inventing another keywor...