List of Major Java 7 Features – How java programming language has changed in JDK 7

Ever wondered what things change in java SE from Java 6 to Java 7 version? Complete list is located here but I am going to focus on the language change. I have provided examples to make it more clear wherever applicable.

  1. The integral types byte, short, int and long can also be expressed as binary number by adding prefix 0b. Some examples below.
    int five = 0b101;
    long someLong = 0b1010000101000101101000010100010111100001010001011010000101000101L;
  2. Underscores in Numeric Literals for readability.
    long million = 1_000_000_000L;
    double length = 123_234.045_456
  3. You can now use String in switch statement
  4. Improvement to Generics – No longer need to specify type in both left and right side. Diamond still required to avoid warning.
    e.g. Map<String, List> myMap = new HashMap<>();
  5. Try-with-resources Statement
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
    return br.readLine();

    In the example above br will be closed regardless of whether the statements within the try block executed normally or got exception. There can be multiple resources defined within the try parenthesis. If there are multiple resources, the last resource is closed first, the first one is closed last.

    try (
    BufferedReader reader = new BufferedReader(new FileReader(path));
    BufferedWriter writer = java.nio.file.Files.newBufferedWriter(outputFilePath, charset)
    ) {

    In this example, writer gets closed first, then the reader gets closed.

  6. Multiple Exception Handling
    catch (IOException|SQLException ex) {
    throw ex;
  7. Rethrowing Exceptions with Improved Type Checking
    public void rethrowException(String exceptionName) throws FirstException, SecondException {
    try {
    // ...
    catch (Exception e) {
    throw e;

    Only FirstException and SecondException are thrown (even if they are declared to be children of Exception). All other exceptions are caught.

[My Video Promotion]
  1. All About Java Garbage Collection : Types, Algorithms, Advantages and Disadvantages
  2. Java Static Import Explained With Easy Example With Source Code
  3. SQL Example To Create Table On MySql DB
  4. Book Review – Drools JBoss Rules 5.X Developer’s Guide by Micahal Bali (Packt Publishing)
  5. List of valid @suppresswarning annotation parameters in Java for Eclipse and IBM RAD IDE
  6. Finding Java System Properties
  7. List of Major Java 7 Features – How java programming language has changed in JDK 7
  8. Date From Timestamp in Long format
  9. How to resolve – java.lang.VerifyError java.lang.SecurityException: Signers of org.junit.runner.Runner do not match signers of other classes in package
  10. Complete List Of Java Keywords
  11. List of 25 Plus Devices That Run On Java
  12. What is the difference between java and javaw?
  13. These 100 plus programming languages run on Java Virtual machine (List)
  14. Read XML File In JAVA using DOM – A Simple Tutorial
Tagged , , , , , , , , , , , , . Bookmark the permalink.

5 Responses to Read XML File In JAVA using DOM – A Simple Tutorial

  1. harry says:

    I need a tutorial on an exact opposite of this excellent article. That is I need to serialize Java Object to XML. Can you help me in that Kushal??? I wud appreciate it a lot.


  2. Jim says:

    Hey Kushal!
    This is very great and helpful, but I got another question about that. If I have an Element which hasn’t any values, I always get a NullpointerException. Do you have an Idea how to fix/catch that?

    Thank you!

  3. Mridula says:

    The advantage in Java is that there it is not necessary to take care of objects which are no longer used. Garbage collector takes care of these objects unlike C/C++ language where because of this issue the program terminates causing OutOfMemoryErrors.

  4. priya says:

    Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.