Top 5 OCPJP7 books for 1Z0-804 and 1Z0-805 Exam - Java SE 7 II Certification

You may know that from Java SE 7 onwards, you need to pass two exams to become a certified Java developer e.g. OCAJP and OCPJP. The first one is an associate level exam and it's rather easy to pass, but the second one OCPJP is a professional level exam and it's much harder than OCAJP. If you are giving the Oracle Java certification then you should know that you need to pass OCAJP before taking OCPJP exam. This is also the second part of an article about books to prepare Java SE 7 certifications. In the first part, I have shared best books for OCAJP7 and in this part, I am going to share best books for the OCPJP7 exam. You might know that there are two professional level exam, 1Z0-804, and 1Z0-805, the first one is known as OCPJP7 while the second one is known as an upgrade to Java SE 7 certification, which you can give to become certified Java SE 7 developer if you already passed SCJP 5 or OCJP 6 exam. The books recommended in this article is applicable to both OCJPJP7 (1Z0-804) and upgrade to Java SE 7 (1Z0-805) exams.

How to implement PreOrder traversal of Binary Tree in Java - Example Tutorial

The easiest way to implement the preOrder traversal of a binary tree in Java is by using recursion. The recursive solution is hardly 3 to 4 lines of code and exactly mimic the steps, but before that, let's revise some basics about a binary tree and preorder traversal. Unlike array and linked list which have just one way to traversed i.e. linearly, binary tree has several ways to traverse all nodes e.g. preorder, postorder and inorder. But, tree traversal algorithms are mainly divided into two categories, the depth-first algorithms, and breadth first algorithms. In depth first, you go deeper into a tree before visiting the sibling node, for example, you go deep following left node before you come back and traverse the right node. On breadth-first traversal, you visit the tree on its breadth i.e. all nodes of one level is visited before you start with another level top to bottom. The PreOrder, InOrder, and PostOrder traversals are all examples of depth-first traversal algorithms.

How to join two ArrayList in Java - Example

You can use the addAll() method from java.util.Collection interface to join two ArrayLists in Java. Since ArrayList implements List interface which actually extends the Collection interface, this method is available to all List implementation including ArrayList e.g. Vector, LinkedList. The Collection.addAll(Collection src) method takes a collection and adds all elements from it to the collection which calls this method e.g. target.addAll(source). After this call, the target will have all elements from both source and target ArrayList, which is like joining two ArrayList in Java. The second ArrayList will remain as it is but the first ArrayList on which you have added elements will have more elements. Its size will be equal to the sum of the size of first and second ArrayList.