View RSS Feed

My Java Tips

  1. Using the JAXP validation framework

    by , 11-28-2011 at 06:29 PM (My Java Tips)
    While working with XML documents, you need to validate the documents. You may use setValidating() method on a SAX or DOM factory. But Java 5.0 (JAXP 1.3) introduces JAXP validation framework which can also be used for validating XML documents.


    Using the JAXP validation framework is fairly simple and efficient. In JAXP 1.3, the validation is broken out into several classes within the new javax.xml.validation package. Lets go through the steps:

    1. Load the model in to ...
    Tags: dom, java 5.0, jaxp, sax Add / Edit Tags
    Categories
    XML , Java EE
  2. @SuppressWarnings annotation

    by , 11-21-2011 at 04:34 PM (My Java Tips)
    In this post, I will be talking briefly about SuppressWarnings annotation.


    Java compiler gives you warnings to assure that you know what is happening. Sometimes, you want donít want the warnings. Java 5.0 provides a way for this.

    One had to use SuppressWarnings annotation to ignore the warnings. Annotations are followed by @.

    For example: consider the following code:
    Java Code:
    int a;
    Object object = new Object();
    I declared two variables ...
  3. Enhanced for-loop (Java 5.0)

    by , 11-20-2011 at 05:14 PM (My Java Tips)
    Java 5.0 introduced an enhanced for-loop. In this post, I'll write about it.


    The enhanced for loop provides a simple structure allows one to simplify code by presenting for-loops that visit each element of an array/collection without explicitly expressing how one goes from element to element.

    The new for loop makes programming simpler. For example, if you want to print each element for an array, you used to do that with a for loop in the following way:

    ...
    Categories
    Java SE