HTML

Binary Search Algorithm using Recursion in Java

In the last article, we have seen the iterative implementation of binary search in Java and in this article, you will learn how to implement binary search using recursion. In order to implement a recursive solution, you need to break the problem into sub-problems until you reach a base case where you know how to solve the problem like sorting an array with one element. Without a base case, your program will never terminate and it will eventually die by throwing the StackOverFlowError. In the case of recursive binary search implementation, we calculate the middle position by taking the start and end position and check if the target element is equal to the middle element or not.

Effective Java 3rd Edition by Joshua Bloch – A Must Read Book for Java Developers

Hello guys, you might have heard about it that Effective Java 3rd Edition is finally available. After 10 years of the long wait by Java programmers from all over the world, finally, an updated version of, probably the most popular Java book on the planet is released now. This new version covers the features and paradigm introduced in JDK 7, 8, and 9.  Joshua Bloch has done a great job in also updating most of the items to keep it relevant to the newer version. Apart from that, there is a whole new chapter added to explain best practices around Java 8 features. I know you don't need any reason to read this book, given its huge popularity and acceptance. Many startups which use Java,  particularly in India, are also distributing copies of this book as a New Year Gift.

How to convert Integer to String in Java - Example

This is the second part of String to Integer data type conversion tutorial in Java, in the first part you have learned how to convert String to Integer and in this article, you will learn the opposite i.e. convert from Integer to String. Actually, you can apply all the tricks, which I had told you before about converting long to String, and autoboxing will take care of converting int to Integer in Java. But, if you care for performance and believe in not using auto-boxing when not needed then there are still a couple of ways which directly converts an Integer object to String e.g. Integer.toString() method, which returns a String object and doesn't have any auto-boxing overhead. Let's see a couple of more ways to convert an Integer to String in Java.

Right Way to Create, Start and Stop a New Thread in Java

One of the most important task for a Java developer is to learn multi-threading and learn it correctly. There are more Java developers who know multi-threading incorrectly than the programmer who doesn't know at all. In order to learn it correctly, you need to start it from scratch, I mean the most fundamental concepts of multithreading like how to create create, start, and stop a new thread in Java. I am sure you already know that as you have done that a lot of time but it's worth remembering few facts to not repeat the mistakes many programmers do when they write multithreading code in Java. In this article, we'll see a couple of those, mainly while creating, starting, and stop threads in Java. So fasten your seatbelt and let's go little deep into threads in Java.

Java CountDownLatch Example - Multithreading and Concurrency Tutorial for Beginners

The CountDownLatch is an important concurrency utility class which was added in JDK 1.5 but unfortunately, many Java developers still struggle to understand and use this powerful tool. You can use CountDownLatch if you are spawning multiple threads to do different jobs and want to know when exactly all tasks are finished so that you can move to the next stage. In other words, you can block a thread until other threads complete their task. One of the good examples where you can use CountDownLatch is an application which downloads data from a database or another application. For example, we are creating a Java program to download all Udemy courses. Since Udemy has thousands of courses, you create different threads to download different categories e.g. technology, development, etc.

Eclipse - Unsupported major.minor version 53.0, 52.00, 51.0 Error in Java

The UnsupportedClassVersionError is a big nightmare for Java developers, probably the next biggest after NoClassDefFoundError and ClassNotFoundException but its slightly easier to solve. The root cause of this error is that your code is compiled using higher JDK version and you are trying to run it on the lower version. For example, the Unsupported major.minor version 53.0 means your code is compiled in JDK 9 (the class version 52 corresponds to JDK 9) and you are trying to run it on any JRE lower than Java 9, probably JDK 8, 7, or 6.

How to do InOrder traversal in Binary tree without Recursion in Java

This is the second part of implementing inorder traversal of a binary tree in Java, in the first part, I have shown you how to solve this problem using recursion and in this part, we'll implement inorder traversal algorithm without recursion. Now, some of you might argue, why use iteration if the recursive solution is so easy to implement? Well, that's true, but the iterative solution is often regarded better as they are not prone to StackOverFlowError. Another reason why we are discussing the iterative solution here is because of technical interviews. If you to go to a programmer job interview, you will find that Interviewer will often ask you to solve the same problem using iteration and recursions like Fibonacci series or String reversal algorithm. It's also good for your learning and developing algorithm skill, which is very important for becoming a better programmer.

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Hello guys, this is one of the common error in a client-server application. The big problem in solving this error is not the error but the knowledge of how client-server SSL handshake works. I have blogged about that before and if you have read that you know that in order to connect to any website or server (like LDAP Server) using SSL, you need to have certificates (public keys) to validate the certificates sends by the website you are connecting. If you don't have the root certificate or public key, which is required to validate the certificate presented by the server in your JRE truststore then Java will throw this error.

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

In order to solve this error, just add the root certificate required to connect to the server in question into truststore of your application's JRE.

10 Things Java Developer Should Know about Lambda Expression of Java 8

The Lambda expression is one of the most important features of Java 8 which has opened a whole new dimension of programming paradigm in Java. It is the feature which made the Functional Programming possible in Java because now you can pass the code to a function to execute as opposed to an object. You might be a bit surprised but if you look from a developer's point of view, it is nothing but a way to pass code to a method in Java. Technically, it's an expression where you can define parameters and then the code which uses those parameters, similar to a method in Java, but you don't need to write boilerplate code e.g. method name, return type, argument type etc. Most of those details are inferred by compiler and JVM from the context in which lambda expression is used.

Difference between WHERE and HAVING clause in SQL?

The main difference between WHERE and HAVING clause comes when used together with GROUP BY clause, In that case WHERE is used to filter rows before grouping and HAVING is used to exclude records after grouping. This is the most important difference and if you remember this, it will help you write better SQL queries. This is also one of the important SQL concepts to understand, not just from an interview perspective but also from a day-to-day use perspective. I am sure you have used WHERE clause because its one of the most common clause in SQL along with SELECT and used to specify filtering criterion or condition. You can even use WHERE clause without HAVING or GROUP BY, as you have seen it many times. 

Top 25 Exception Interview Questions for Java Programmers

1) The difference between checked and unchecked Exception in Java?
For checked exceptions, the compiler ensures that they are either handled using try-catch, try-finally or try-catch-finally block or thrown away. If a method, which throws a checked exception e.g IOException and doesn't handle them or doesn't declare them in throws class of method, a compile-time error will occur. On the other hand, the compiler doesn't do similar checks for an unchecked exception, that's why it is known as un-checked. These are also called runtime exception because they extend java.lang.RuntimeException.

Top 10 Open Source Frameworks and Libraries Java Web Developers Can Learn in 2019

Java programming language and Platform has been very lucky in terms of frameworks, standards, and libraries, I guess which is one of the important reason for its huge success. Apart from standard frameworks like Swing for desktop GUI application, JavaFX, Servlets and JSP, EJB, and JSF, there are a lot more open source framework and libraries available for Java programmers. These Open source framework, not only helps and speed up development but also enforce to use best practices required to build enterprise Java application and desktop application. Frameworks like Spring, which in my opinion gives a much-needed boost to the Java platform, enforces dependency Injection design principle at the core, which is key to build a loosely coupled system.

5 Examples of Enhanced for loop in Java

Enhanced for loop was added way back in 2004 in Java and it provides an easy and cleaner way to iterate over array and Collection in Java. The introduction of forEach() in Java 8 has further improved iteration but that doesn't mean that you need to forget the for each loop. In this article, you'll see some cool examples of enhanced for loop in Java which will help you to write better and more readable code in Java. It's also less error-prone because you don't have to deal with an index like you need to with the classic "for" loop. This means no chance of one-off error, means no risk of starting with index zero when you want to start with one or vice-versa.

Difference between OCAJP and OCPJP Certification Exams for Java Programmers

Earlier when Sun Microsystems was in charge of Java, the popular Java certifications were called "Sun Certified Java Programmer" or "SCJP" and that time there was just one exam, you need to pass to become a certified Java Developer, but when Oracle took over Sun Microsystems on 2010, the SCJP goes away and OCAJP and OCPJP born. Since Oracle already has his certifications for database administrations e.g. OCA which stands for Oracle certified associates and OCP, which stands for Oracle Certified Professional, it introduces new Java certifications to match their existing hierarchy and they are known as OCAJP and OCPJP in the Java world.

Top 5 Amazing Gifts for Programmers, Coders, and Software Developers

If you are planning for a surprise gift to your programmer boyfriend and husband on this holiday season e.g. Black Friday, on Christmas, or New Year or maybe on his next birthday, but not sure what to gift, then you have come to the right place. In this article, I am going to share some of the best gifts every programmer wish for. To be honest with you, buying a gift is easy but finding the right gift is very tough. I have spent countless hours on the internet to find a perfect gift for one of my colleague's husband and this article is a result of that research. The general perception of programmers is that they are a nerd, they love books, gadgets, cool stuff, music, but the perfect gift is something which not only provides the enjoyment but also the value.