Java 5 supports a so-called For-Each loop. Here is an example:
public class Foo {
public static void main(String[] args) {
String []names = new String[]{"Paul", "Kent", "Bill"};
for (String name: names) {
System.out.println(name);
}
}
}
The variable "name" will be set to each element in the array in each turn. So in this case it will print the three names in the array. For-each not only works on array, but also on any Collection (e.g., List, Set, Map):
public class Foo {
public static void main(String[] args) {
List objs = new ArrayList();
objs.add("Paul");
objs.add(10);
objs.add(5.4);
for (Object obj: objs) {
System.out.println(obj);
}
}
}
Here the variable "obj" will be set to each element in the List. Got
it? Now, click here to
take a quiz to see if you have really understood.The next version of J2EE, Java EE 5, has been released. It includes the following new specifications: JSF 1.2, JSP 2.1, EJB 3.0, JAX-WS. In particular, EJB 3 has incorporated features from Spring such as the use of POJO (Plain Old Java Object) and from Hibernate and TopLink (for storing Java objects into databases).
Oracle's JDeveloper is another great IDE for Java at no cost. Unlike Eclipse, it supports visual editing of JSF. Check out this tutorial on building a JSF application with it.
You can write PHP code in Eclipse using the PHPeclipse plugin. It allows you to debug your PHP code when it's running in Apache. Check out this tutorial on PHPeclipse debugging.
If you'd like to prepare for the MCAD/MCSD certifications, check out the following books in the MCAD/MCSD Self-Paced Training Kit:
They're all available at the Cyber-Lab Library
for borrowing at no charge.
Have any questions, ideas or experiences regarding software development? Contact me at 781313 or kent at cpttm dot org dot mo.
Until next time,
Kent Tong