HTML

How to Send HTTP Request from Java Program - Example Tutorial

If you are thinking is it possible to send an HTTP request from a Java program and if yes, how to send a simple HTTP GET request in Java, then you have come to the right place. In this article, I'll show you how you can use the HttpURLConnection class from java.net package to send a simple HTTP request in Java. But, first let me answer your first question, is it possible to send HTTP request in Java? Yes, it's possible and you can send any kind of HTTP request e.g. GET, POST, PUT, DELETE, HEAD, or PATCH. The java.net package provides a class called HttpURLConnection, which can be used to send any kind of HTTP or HTTPS request from Java program.

100+ Data Structure and Algorithm Interview Questions Answers for Programmers

Data structure and algorithms are core part of any Programming job interview. It doesn't matter whether you are a C++ developer, a Java developer or a Web developer working in JavaScript, Angular, React, or Query. As a computer science graduate, its expected from a programmer to have strong knowledge of both basic data structures e.g. array, linked list, binary tree, hash table, stack, queue and advanced data structures like the binary heap, trie, self-balanced tree, circular buffer etc. I have taken a lot of Java interviews for both junior and senior positions in the past, and I have been also involved in interviewing C++ developer. One difference which I have clearly noticed between a C++ and a Java developer is their understanding and command of Data structure and algorithms.

5 Free Servlet, JSP, and JDBC Online Courses for Advanced Java Developers

If you are a Java developer working on a Java JEE projects e.g. Java web application or you want to get into that by learning server-side technologies like Servlet, JSP, and JDBC then you have come to the right place. In this article, I will share some free online courses to learn Servlet, JSP, and JDBC at your own pace. If you want to become a rockstar Java web developer then you must have a good understanding of these basic web technologies before you learn frameworks like Spring and Hibernate. These frameworks work on top of these basic technologies and if you don't know them then you would often struggle to debug and troubleshoot problems in real world.

How to Set Specific Java Version for Maven in Windows?

Maven is a great build tool and most of the Java developer uses Maven to build their projects, but like any other tool, there are some intricacies which you need to know while using it. One of them is that Maven uses Java version from the JAVA_HOME environment variable and not the PATH environment variable. If you have multiple JDK installed on your machine and getting an Unsupported major.minor version 51.0 or Unsupported major.minor version 52.0 error while building your project but have right Java version in PATH then you may need to check the JAVA_HOME and update it. If you don't have access to do it then you can still change JAVA_HOME using set command in your local shell and run the Maven's mvn command to build the project

Why you should not use SELECT * in SQL Query

I have read many articles on the internet where people suggest that using SELECT * in SQL query is a bad practice and you should always avoid that. Instead, you should always use an explicit list of columns. That's a good suggestion and one of the SQL best practice I teach to junior developers, but many of them don't explain the reason behind it.  Unless you explain some reasons why one should not use SELECT * in queries, it's difficult to convince many SQL developers,  many of whom have started learning SQL by doing SELECT * from EMP in Oracle database. In this article, I will try to bridge that gap by giving some practical reasons of why using SELECT * in Query is not a good idea.

5 Free Blockchain Technology Courses for Programmers

Hello guys, how are you doing? hope you all are having a great time and working towards your goal in 2018. I have been sharing a lot of courses and tutorials in this blog about what to learn in 2018, starting from tools to frameworks, from libraries to programming languages, but one of the most important technology, you can learn in in 2018 is the Blockchain technology. It's one of most talked about technology at the moment and considered to be the next big thing after the invention of the internet as they provide a way to attain digital trust on the Internet.

Top 5 Free Angular Courses for Web Developers to Learn Online

Angular is one of the most popular JavaScript frameworks for creating web apps. It helps you in creating complex web applications in less time. It's maintained by Google so you can also rest assured that this powerhouse of a framework is built with speed and purpose and here for a long run.  Angular is also the most popular framework in the world for building single page applications.  The framework was first launched as Angular JS which allowed building a web application using Model View Controller concept and it was hugely popular but it was later re-written completely, which is now known as simply Angular or Angular 2. Even though many web developers use Angular and Angular JS interchangeably they are very different and don't share anything expect Angular in their Name.

Top 20 System Design Interview Questions for Java Programmers

System design questions are an important part of programming job interviews and if you want to do well, you must prepare this topic. In the past, when I shared my list of programming interview questions, I have shared a couple of System design questions but my readers kept asking me for more questions, as it is a hard topic to master and more and more practice is needed. I had my own list of questions which I have collected from various interviews with friends and colleagues but I needed more questions for this article and my own preparation then I stumbled upon Grokking System Design Interview course. It's an excellent resource because it not only gives you a lot of System design question but also provide all the knowledge and tools you need to solve those questions.

5 Free Apache Spark Course for Java, Scala, and Python Programmers to learn Online

Hello guys, if you are thinking to learn Apache Spark to start your Big Data journey and looking for some awesome free resources e.g. books, tutorials, and courses then you have come to the right place. In this article, I am going to share some of the best, free online Apache Spark courses for Java, Scala and Python developers. If you don't know what is Apache Spark? and Why it's so important in Big Data world then let me give you a brief overview first. Apache Spark is another cluster computing framework like Hadoop which is used to analyze a huge data set, but it's much faster as compared to Hadoop which makes it ideal for today's high computing needs e.g. processing huge amount of data.

5 Difference between BufferedReader and Scanner class in Java - File Tutorial Example

Hello guys, welcome to my blog. Today, we'll discuss another interesting Java interview questions, BufferedReader vs Scanner. It's not only important from interview point of view but also to work efficiently with Java. Even though both BufferedReader and Scanner can read a file or user input from the command prompt in Java, there some significant differences between them. One of the main difference between BufferedReader and Scanner class is that former class is meant to just read String or text data while Scanner class is meant to both read and parse text data into Java primitive types like int, short, float, double, and long.

How to Convert a List or Set of String to comma separated String (CSV) in Java 8

Before Java 8, it was not straightforward to convert a list of String to a comma separated String. You have to loop through the collection or list and join them manually using String concatenation, which can take up more than 4 lines of code. Of course, you could encapsulate that into your own utility method and you should but JDK didn't provide anything useful for such a common operation. Btw, things have changed. From Java 8 onwards you can do this easily. JDK 8 has provided a utility class called StringJoiner as well as added a join() method into String class to convert a List, Set, Collection or even array of String objects to a comma separated String in Java.

Top 5 Free Spring Core Professional Certification Mock Exams and Practice Questions

Many Java developers don't know that similar to Oracle's Java certification, there is also a Spring certification program, which certifies yourself for your Spring framework skill. There are three Spring certifications currently available, Spring Professional certification exam, which certifies on your general knowledge about Spring framework, Spring Web Application Developer exam, which certifies you about your Spring MVC skill and Spring Enterprise Integration Specialist certification exam, which is for advanced Spring Integration skill. Earlier, SpringSource provides these certifications but now they are provided by Pivotal, the company behind the Spring framework.

Difference between final vs finally and finalize in Java? Answer

The final, finally, and finalize are one of the three confusing keywords, modifiers and methods in Java. They sound similar but they are for different purpose. For example, the final keyword is a modifier in Java. When you use the final keyword with a class it becomes a final class and no one can extend this e.g. String is final in Java. When you use the final modifier with method than it cannot be overridden in a subclass, and when you use the final keyword with a variable, it becomes a constant i.e. its value cannot be changed once assigned. On the other hand, finally is a keyword related to exception handling in Java. It's often used with try block and it's part of try, catch and finally trio.

Top 10 Web, Mobile, and Big Data Technologies Programmers Should Learn in 2018

Hello Guys, we are already in the second week of 2018 now and many of you have made your goals about what to learn in 2018, but if you haven't then you have come to the right place. In this article, I am sharing some of the best framework and libraries for web development, mobile app development, and big data, an application developer can learn in 2018. The New Year will be all about the mobile and next-generation web with a greater focus on big data technologies like Hadoop and Spark, but you can still learn the popular Java and Web development frameworks like React, Node.js, Spring Boot to take your career to next level. These frameworks are tried and tested and will be here for at least next 5 years to come.

How to add/remove new elements to an array in Java?

Java beginners often ask how to add new elements to an array? or how to remove elements from an array in Java? is that possible in Java? Well, no, it's not possible in Java because arrays length cannot be changed once created. Which means neither you can add new elements nor you can remove an old one. All you can do is that reassign values to the different bucket. For example, if you have a String array of length 3 e.g. {"java", "is", "great"} then you can just replace the individual index to make it like {"Python", "is", "great"} by replace "java" with "Python" at first index, but you cannot add or remove elements.

How to Print all leaf Nodes of a Binary tree in Java - Coding Interview Questions

This is another interesting coding problem which is based on a binary tree and mostly asked beginner programmers. If you have some experience in solving binary tree based problems then it's rather easy to solve because, like many other binary tree algorithms, you can use recursion to print all leaf nodes of a binary tree in Java. Since the tree is a recursive data structure, you can apply the same algorithm to both the left and right subtree. In order to solve this problem, the first thing you should know is what is a leaf node because if you don't know that then you won't be able to solve the problem. Well, a leaf node is the one who's left and right child nodes are null.

How to Reverse a String in place in Java - Example

One of the common Java coding interview questions is to write a program to reverse a String in place in Java, without using additional memory. You cannot use any library classes or methods like e.g. StringBuilder to solve this problem. This restriction is placed because StringBuilder and StringBuffer class define a reverse() method which can easily reverse the given String. Since the main objective of this question is to test the programming skill and coding logic of candidate, there is no point giving him the option to use the library method which can make this question trivial. Now, how do you solve this problem? If you are familiar with array data structure then it would be easy for you. Since String is backed by a character array, you can use the same in place algorithm we have used to reverse an array in place.

How to use ConcurrentHashSet from ConcurrentHashMap in Java 8 - Example Tutorial

There is no ConcurrentHashSet in JDK 8 but you can still create one for yourself by using the ConcurrentHashMap class of java.util.concurrent package. There is a new method added into ConcurrentHashMap in JDK 8, newKeySet(), which allows you to create a concurrent hash set backed by a concurrent hash map. If you remember whenever you get keys from the map they are returned in a Set e.g. for the old keySet() method because map only has unique keys. Since map doesn't allow duplicate keys, it can be used as a set, as long as you only care for keys or just one element. That's why Java designers are added newKeySet() method to convert a map to set. This is also a static method, which means you don't need a ConcurrentHashMap object to create a concurrent hash set.

Top 10 Spring Framework Annotations for Java Developers

There is no doubt that Spring framework is one of the most popular Java frameworks and it has made the life of Java developer easy by providing some awesome features in the last 15 years. Spring uses dependency injection to configure and bind your application together but it doesn't force you to implement one of its interfaces. This allows you to code POJO (plain old Java objects), a class with methods and attributes to do most of your stuff. Then the questions come, how do Spring provides those magical features if it doesn't ask you to implement their interface, well they use annotations and many of them. You will find some of the most common annotations in this article, which is must for a Java developer to work with Spring.

Top 10 Data Science and Machine Learning Certification Courses to Learn Online - Best of Lot

If you work in the technology field today like you are a programmer or software engineer then I am sure you have heard about terms like Data Science, Machine Learning, Deep Learning, Artificial Intelligence etc. They are the latest technologies which are impacting every single sector just like IT does it when it comes the first time. It doesn't matter if you are working for a bank or insurance sector, airspace or defense, all fields were impacted by IT and in near future, they will be impacted by machine learning and artificial intelligence. If you are wondering, let me give you a brief overview. Machine learning is all about training machines to do the job which was only possible by humans before, for example seeing a photo and recognizing what is the object like a car, a human or a cucumber.

5 Free Database and SQL Query Courses for Programmers to Learn Online

Hello guys, I have been sharing some free programming resources e.g. books and courses in this blog for quite some time. Earlier I have shared free courses on Java, Maven, Spring, and Data Structure and Algorithms and today I'll share some of the free online training courses to learn SQL and Database. Why you should learn SQL? Well, it's one of the must-have skill for programmers, application developer, and IT professionals. Like Linux, this is one skill which is going to serve you longer than any other programming language, framework, or library.

5 Free Docker Courses for Java and DevOps Engineers

If you are an application developer working in Java or C# or any other language and wants to become a DevOps engineer or someone who wants to learn Docker then you have come to the right place. In this article, I am going to share some of the free Docker courses you can use take online to learn Docker by yourself. These courses are great for both beginners and intermediate developers who have basic ideas about Docker. If you don't know what is a Docker and how it works then let me give you a brief introduction. Before starting just look at the Docker's logo which is a whale carrying containers, does that strike something? Well, if you add this image with the name Docker you might think about shipping companies, which carry containers from one part of the world to another.

3 Examples to Generate Random Integers on a Range in Java

Manytimes you need to generate random numbers, particular integers in a range but unfortunately, JDK doesn't provide a simple method like nextIntegerBetween(int minInclusive, int maxExclusive), because of that many Java progarmmers, particularly beginners struggle to generate random numbers between a range e.g. random integers between 1 to 6 if you are creating a game of dice, or random number between 1 to 52 if you are creating a game of playing cards and you need to choose a random card, or most commonly random numbers between 1 to 10 and 1 to 100. Then, the question comes, how to solve this problem? How to generate random int values between a range? Well, you need to do a little bit of work.

5 Difference between an array and linked list in Java

The difference between an array and linked list is one of the frequently asked data structure and algorithm interview question and you might have seen it before on your telephonic or face-to-face interview. It is also a very popular question during practical exams in Computer Science degree courses e.g. B.E. and B.Tech. It's very simple and easy to answer but you just can't afford to miss this question in an interview. Both array and linked list are two of the most popular and fundamental data structure in Computer Science and Programming, and Java supports both of them. One of the traits of a good programmer is extensive knowledge of data structure and algorithm and that's why it's very important for you to learn the difference between array and linked list data structure and understand when to use an array over a linked list and vice-versa.

How to Find Large Files with Size in Linux to Free Disk Space? find and du command example

One of the common problem while working in Linux is to find large files to free some space. Suppose, your file system is full and you are receiving an alert to remove spaces or if your host is run out of space and your server is not starting up, the first thing you do is find top 10 largest files and see if you can delete them. Usually, old files, large Java heap dumps are good candidates for removal and freeing up some space. If you are running Java application e.g. core Java-based programs or web application running on Tomcat then you can remove those heap dump files and free some space, but the big question is how do you find those? How do you know the size of the biggest file in your file system, especially if you don't know which directory it is? We'll try to find answers for some of those questions in this article.

How to Convert a List into Map in Java 8 - Example Tutorial

One of the common tasks in Java programming is to convert a list to map and I have written about this in past and today we'll see how Java 8 makes this task easier. Btw, be it Java 7 or Java 8, you need to keep something in mind while converting a list to map because they are two different data structure. For example, the list allows duplicate elements but keys in a map must be unique, the value can be duplicated but a duplicate key may cause a problem in Java 8. Similarly, another concern is order. A list is an ordered collection but the map doesn't guarantee any order unless you decide to use LinkedHashMap, which keeps insertion order or TreeMap which keeps mapping in the sorted order of keys. This is one of the important details which many Java beginners forget and then spend hours to chase subtle bugs.

5 Free Oracle and Microsoft SQL Server Online Courses

If you are an application developer e.g. someone developing a server-side application using Java or .NET or any other programming language which uses a database like Oracle and Microsoft SQL Server or a junior DBA then you must learn these database technologies to effectively work in your Job. Even though your organization might have DBAs or Database Administrators to help you with the database, more often than not, it's application developers who end up writing SQL scripts to create data, upload data, query data, and writing complex stored procedures and triggers to implement application functionalities. DBAs job mostly does database installation, access control, security and other database admin stuff.

Top 10 Java 8 Tutorials and Courses - Best of Lot, Must Read

It's almost six months since Java 8 was released and there are so many Java 8 tutorials are written by Oracle, bloggers, and other peoples, but which should you read? Which tutorials are worth of your time? Actually, this question is asked to me by one of my reader called John, he was asking me about some good Java 8 tutorials, which he can read to start with. This encouraged me to take a look at some of the Java 8 tutorials available on the internet and form a list of best. I have just used three criterion, content, language and length. Because tutorials complement books, they should not be like the book. They should be small enough to complete in few hours and complete enough to give useful information. I also like tutorials, which discusses practical problems and examples.

Java 8 compute() and computeIfPresent() Example

The JDK 8 has added several useful methods in existing interfaces e.g. java.util.Map, java.util.Collection, and java.util.concurrent.ConcurrentMap. Thanks to default methods, the much-needed evolution of existing interfaces become possible. Out of many useful methods, one method which stands out to me is the compute() method, which allows you to update a value in ConcurrentHashMap atomically. As per Java documentation, The compute() function tries to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping). The entire function is performed atomically.

Top 5 Spring Security Online Training Courses for Java Developers

Security is one of the most important aspects of a modern web application, be it a Java web application, .NET or writing using any other web technology. In Java world, Spring Security rule the security space. It's one of the rare frameworks which provided many security features e.g. authentication, authorization, session management, remember me and several other useful features out-of-the-box. Since there was no competition to Spring security and it does it job very well, it soon becomes the de-facto standard for implementing security in both Java web applications, REST APIs and core Java applications. The rise of Spring framework certainly helps it to cement its place as well.

How to Convert a LinkedList to an Array in Java? Example

You can convert a LinkedList to an array in Java by using the toArray() method of the java.util.LinkedList class. The toArray() method accepts an array of relevant type to store contents of LinkedList. It stores the elements in the array in the same order they are currently inside the LinkedList. By using the toArray() method you can convert any type of LinkedList e.g. Integer, String or Float to any type of Array, only catch is this you cannot convert a LinkedList to an array of primitives i.e. a LinkedList of Integer cannot be converted into an array of ints by using toArray() method, but you can convert it to array of Integer objects, that's perfectly Ok.

5 ways to Compare String Objects in Java - Example Tutorial

here are many ways to compare String in Java e.g. you can use equals() and equalsIgnoreCase() for equality check and compare() and compareTo() for ordering comparison. You can even use the equality operator == to perform reference based comparison e.g. to check both the String reference variable points to the same object. In general, equals() is used to check whether the value of given String is same i.e. they contain same characters in the same sequence or not e.g. "Groovy".equals("Groovy") will be true if you compare them using equals() method. You can also use equalsIgnoreCase() to check if they are equal irrespective of case e.g. "Apple" and "apple" will be same if you compare them using equalsIgnoreCase() method.

How to Count number of 1s (Set Bits) in Given Bit Sequence in Java

Good morning folks, In today's article, we are going to discuss one of the frequently asked bit manipulation based interview question, how do you count the number of set bits in given bit sequence?  Bit Manipulation is an important topic on programming interview and a good programmer should have sufficient knowledge and skill to work with binary numbers. This kind of questions tests that skill of the programmer. Sometimes, it is also asked as for how to count the number of 1s (ones) in given number? Both are the same question because 1 is also known as set bit.  For example, if given input is 1000110010 than your program should return 4, as three are only four set bits in this bit sequence.

Can you Make a Class Static in Java? Interview Question

This is one of the tricky questions in Java because there is no straight forward Yes and No answer here. You cannot make a top level class static in Java but Yes, you can make a nested class static in Java. In fact, it is even advised (see Effective Java) to prefer a nested static class in Java than normal inner classes. Now, the question comes what is a top level class and what is a nested class in Java? Well, you can declare multiple classes in a single Java source file. A class is said to be top level if it is not inside any other class and a class which is inside another class is known as nested class. You can create nested class inside another top level or another nested class in Java. This is the class which can be static in Java.

Top 20 Hibernate Interview Questions for Java J2EE Programmers

Hibernate is one of the most popular persistent frameworks in Java world. Hibernate offers object to relational (ORM) solution which frees Java developers from writing tedious, hard to read and cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developer from writing JDBC and database interaction code, Hibernate also offers the out-of-box solution on caching, proxying and lazy loading which drastically improves the performance of your Java Web application. Given it's important in Java Web application development field Hibernate has become of one of the most sought-after skill and goes hand in hand with Spring framework. That's why Spring and Hibernate interview questions are also very popular in Java interviews, particularly for web development positions.

3 Examples to Loop Through a List in Java 8

3 ways to Loop through a List in Java
There are multiple ways to traverse or loop through a List in Java e.g. by using an Iterator, by using an enhanced for loop of Java 5, and not the forEach() method of Java 8. Given a List is an index based collection if you know the index you can retrieve an object from List and because of this, you can also use traditional for loop which keeps count for iterating List. Now the question is whether should you use the Iterator or enhanced for loop, or the forEach() method of Java 8 for looping over List in Java. Well, it depends on what you are doing with the object, if you need to remove some objects from List than iterating using Iterator is best choice to avoid ConcurrentModificationExceptionbut if you are not removing any element and just doing some operation with each element than enhanced for loop is much cleaner ways to do that. 

Is Java The best language to learn Programming/Coding for Beginners?

I often receive questions like which is a good programming language to learn first, Is Java a good programming language to start with,  how good Java is as a first programming language, which is the best programming language for beginners, or shall I start with Java or Python. Well, the answer to all these questions is, Java is one of the most popular programming languages and there are the lot of reasons to learn Java, starting with Job opportunity to leverage community support. In the context of starting programming or choosing Java as the first language, my biggest reason is that it's simpler to learn. The last generation of programmers started learning to programme using languages like BASIC and then grew up learning C and C++ with Java as their second or third programming language.

JDBC - Difference between PreparedStatement and Statement in Java

If you have worked with database interfacing with Java using JDBC API then you may know that the JDBC API provides three types of Statement for wrapping an SQL query and sending for execution to the database, they are aptly named as Statement, PreparedStatement, and CallableStatement. First one, Statement is used to execute normal SQL queries e.g. select count(*) from Courses. You can also use it to execute DDL, DML and DCL SQL statements. The second one, PreparedStatement is specialized to execute parameterized queries e.g. select * from Courses where courseId=?, you can execute this SQL multiple times by just changing the course parameters. They are compiled and cached at database end, hence quite fast for repeated execution.

Difference between ISNULL and COALESCE T-SQL Function in Microsoft SQL Server - Interview Questions

Even though both ISNULL() and COALESCE() function provides alternate values to NULL in T-SQL and Microsoft SQL Server e.g. replacing NULL values with empty String, there are some key differences between them, which is often the topic of SQL Server interview. In this article, you will not only learn the answer to this question but also learn how to use COALESCE and ISNULL function properly. One the main difference between them is that  COALESCE() is a standard SQL function but ISNULL() is a Microsoft SQL Server specific, which means it's not guaranteed to be supported by other database vendors like Oracle, MySQL or PostgreSQL.

How to Convert a Comma Separated String to an ArrayList in Java - Example Tutorial

Suppose you have a comma-separated list of String e.g. "Samsung, Apple, Sony, Google, Microsoft, Amazon" and you want to convert it into an ArrayList containing all String elements e.g. Samsung, Apple, Google etc. How do you do that? Well, Java doesn't provide any such constructor or factory method to create ArrayList from delimited String, but you can use String.split() method and Arrays.asList() method together to create an ArrayList from any delimited String, not just comma separated one. All you need to do is first split the given String on delimiter e.g. comma using the split() method, this will give you an array of String. Now, you can pass that array to Arrays.asList() method to create a List, but remember this would be fixed length list and not truly an ArrayList.

3 Books and Courses to Learn RESTful Web Services using Spring and Java

Even though the Spring in Action 4th Edition is a good book to learn Spring framework, its not enough to learn intricacies of developing RESTful Web Service using Spring Frameowrk. It does have a chapter on developing RESTful Web Services and nicely explains concepts like @RestController, @ResponseBody, @ResponseStatus, HTTP message converters, content negotation but that barely touch the surface of developing a production quality RESTFul Web Service. There are many other things e.g. filtering, pagination, error handling, and security of RESTful Web services using Spring and Spring security which is not covered.

10 Examples of Array Data Structure in Java - Tutorial

Along with the String, the array is the most used data structure in Java. In fact, String is also backed by a character array in Java and other programming languages. It's very important for a Java programmer to have good knowledge of array and how to do common things with array e.g. initialization, searching, sorting, printing array in a meaningful way, comparing array, converting an array to String or ArrayList and doing some advanced slicing and dicing operation with an array in Java. Like my previous tutorials 10 example of HashMap in Java, I'll show you some practical example of array in Java. If you think, any important operation is not included, you can suggest their examples and I'll add them to this list.

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.

Java Enum With Constructor Example

Java Enum with Constructor
Many Java developers don't know that Java Enum can have a constructor to pass data while creating Enum constants. This feature allows you to associate related data together. One example of passing arguments to enum Constructor is our TrafficLight Enum where we pass action to each Enum instance e.g. GREEN is associate with go, RED is associated with stop and ORANGE is associated with the slow down. This is really useful because it provides more context and meaning to your code. If you want, you can also provide one or more constructor to your Enum as it also supports constructor overloading like normal Java classes. This is very different from enum you have seen in C or C++, which is just a collection of fixed thing without any OOP power.

Top 5 Free jQuery Courses for Web Developers - Best of Lot

Hello guys, if you are thinking to learn jQuery and looking for some awesome free resources e.g. books, tutorials, and online courses then you have come to the right place. In this article, I am going to share some of the best free jQuery courses from Udemy and Pluarlsight which you can take to learn this awesome JavaScript library. In the past, I have also shared some free books and tutorials on jQuery, which complements these courses. You can also take a look at then while learning different parts of jQuery.
Before I share these free courses, let me brief you about what jQuery is and why you should learn it? Well, jQuery is a JavaScript library but unlike any other library it is very powerful and makes the client side scripting really easy.

10 Examples of Collectors in Java 8

As the name suggests, Collectors class is used to collect elements of a Stream into Collection. It acts as a bridge between Stream and Collection and you can use it to convert a Stream into different types of Collections e.g. List, Set, Map. Btw, it not just limited to that, it even provides functionalities to join String, group by, partition by and several other reduction operators to return a meaningful result. It's often used along with collect() method of Stream class which accepts a Collectors. In this article, we'll learn Collectors by following some hands-on examples.

How to Implement a Power Function in Java - Coding Interview Problems

Even though the Java library has a power function, Math.pow() to calculate the power of a given number in Java, it's a common programming exercise for Java programmer to implement a power function. If you have used the Math class then you know that the java.lang.Math.pow(double a, double b) returns the value of the first number raised to the power of the second number and you need to do the same. In other words, you need to write a Java function to calculate the power of integer numbers for simplicity. The original method accepts a double value but you are allowed to use just integer but beware that power function may overflow.

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.

Java 8 Default Methods FAQ - Frequently asked Questions and Answers

In last a couple of articles, I have to talk about default methods introduced in JDK 8. First, we have learned what is default method and why it is introduced in Java. Then we have seen the example of how you can use default methods to evolve your interface. After that we have analyzed does Java really support multiple inheritances now in JDK 8 (see here) and how will Java handle the diamond problem that will arise due to default methods. For example, what will happen if a class extend a class and implement an interface and both contain a concrete method with same method signature? Will a diamond problem arise? How will Java handle that and how you can solve it, and the difference between abstract class and interface in Java 8?  Once you went through those articles, you would have a good knowledge of default methods in Java 8.

Difference between wait() and join method in Java thread

Though both wait() and join() methods are used to pause the current thread and have a lot of similarities they have different purposes. One of the most obvious differences between the wait() and join() method is that former is declared in java.lang.Object class while join() is declared in java.lang.Thread class. This means that wait() is related to the monitor lock which is held by each instance of an object and join method is related to Thread itself. The wait() method is used in conjunction with notify() and notifyAll() method for inter-thread communication, but join() is used in Java multi-threading to wait until one thread finishes its execution.

Top 10 Java 8 Stream and Functional Programming Interview Questions Answers

The JDK 8 release has changed the way we write Java. With new functional programming idioms and a powerful Stream API, most of the new Java code is written in functional style. This also means that Stream and Functional programming related questions are increasing on Java interviews. If you are not familiar with Java 8 changes then it's difficult to crack a Java interview nowadays. Though it's not stated anywhere most of the companies now expect Java developers to know at least Java 8, which is also good right? Java 11 is already out and we are looking forward to Java 12 in a couple of months, it makes sense to know at least Java 8 changes.  Since more and more of my readers are asking about Java 8 interview questions to me, I have started a series where I take one or two topics and share 15 to 20 interview questions.

Difference between @SpringBootApplication vs @EnableAutoConfiguration annotations in Spring Boot

Even though both @SpringBootApplication and @EnableAutoConfiguration can be used to enable the auto-configuration feature of Spring Boot there is a subtle difference between them. The @SpringBootApplication does much more than what @EnableAutoConfiguration do. It's actually a combination of three annotations: @Configuration which is used in Java-based configuration on Spring framework, @ComponentScan to enable component scanning of components you write e.g. @Controller classes, and @EnableAutoConfgiuration itself, which is used to enable auto-configuration in Spring Boot application. Spring Boot designers realize that these three annotations are frequently used together so they bundled them into @SpringBootApplicaiton. Now, instead of three annotations you just need to specify one annotation on your Main class.

How to use Callable Statement in Java to call Stored Procedure? JDBC Example

The CallableStatement of JDBC API is used to call a stored procedure from Java Program. Calling a stored procedure follows the same pattern as creating PreparedStatment and than executing it. You first need to create a database connection by supplying all the relevant details e.g. database URL, which comprise JDBC protocol and hostname, username, and password. Make sure your JDBC URL is acceptable by JDBC driver you are using to connect to the database. Every database vendor uses different JDBC URL and they have different driver JAR which must be in your classpath before you can run the stored procedure from Java Program.

Top 5 Free React JS Courses for Web Developers to Learn Online

React JS is one of the most popular frameworks or Javascript library for building user interfaces. It's backed by Facebook and it's often viewed as an alternative to the Angular framework by Google. React is also very flexible, fast, easy to learn and fun to work with. It is designed to make the process of building modular, reusable user interface components simple and intuitive and that's why most of the modern GUI and web applications are build using React framework. It is developed at Facebook and focuses on the 'View' aspect of MVC in web applications. React was built for the purpose of developing applications that are large in nature and have to deal with time changing data.  So if you need fast refresh i.e. updating individual component without updating whole DOM then React is the right framework.

10 High Paying Technologies Programmers Can Learn in 2018

Since last a couple of the week, I have been doing some research about what to learn in 2018 when I stumbled about StackOverflow's Developer Survey for 2017. It's one of the best surveys for software developers, which provides useful insights about programming and IT world. One of the things I really like about this survey was its several lists e.g. the list of top 10 programming languages and the most loved frameworks by programmers, but the one I found most useful was the list of top paying technologies. This is a great list and allow you to choose what you can learn in 2018 to go to the next level in your career in terms of both financial and career growth.

A Beginners Guide to Package in Java

If you are learning Java then you might have come across package concept and if you are wondering what is package and why should we use it then you have come to the right place. In this article, I will explain what is package in Java and other stuff around the package, including some best practices which using the package in Java. In the simplest form, a package is a way to organize related functionality or code in single place in Java. If you look from File System perspective then a package in Java just represent a directory where Java source file is stored in compilation and class files are stored after compilation. For example, if you create a class HelloWorld in a package called com.java67.welcome; then it will reside under directory com/java67/welcome in the source tree and you can view that in your IDE like Eclipse or Netbeans or even by navigating to file system.

Java CountDownLatch Example - Multithreading and Concurrency Tutorial

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 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.

5 Free Python Courses for Beginners to Learn Online

Hello guys, If you are a beginner looking for some Free Python resources to start your programming journey then you have come to the right place. Earlier, I have shared a couple of free Python Programming eBooks sand today I'll share a couple of good Python programming courses which are absolutely FREE!! You can take these online courses to learn Python at your own pace, at your own time, and at your place. This is a great advantage of online learning, the flexibility it provides is just awesome.  You just need a laptop or a smartphone with an internet connection and you can learn anything. Btw, before to start with the list of courses to learn Python programming I want to congratulate you for making the right decision to start your programming journey with Python.

Difference between Abstract class and Interface in Java 8

Ever since JDK 8 has allowed concrete (non-abstract) methods on the interface like default and static methods, many of my readers have asked me how should they answer the classical abstract class vs interface questions. Earlier, an interface cannot have any concrete methods and that was the main difference between abstract class and interface but now that is not the case. In this post, I'll revisit this hugely popular Java interview question in light of Java 8 changes. As I said, before JDK 8, the level of abstraction was the clear-cut difference between abstract class and interface i.e. interface was the purest form of abstraction which only defines what interface is supposed to do without specifying how they should be implemented, in other words, it only declares API methods and leaves implementation to its subclasses.

5 Free Ruby and Rails Courses to Learn Online

Hello guys, welcome to this post, here you will find some of the best free courses to learn Ruby programming language and Ruby on Rails framework online. If you don't know what is Ruby and what is Rails framework then let me tell you that its one of the simplest programming language with little to no syntax. If you are new to programming or never coded before then also developing a Ruby application will be much easier than choosing any other programming language like Python or Java. When it comes to developing web development, the Ruby on Rails also makes your job easy by making several useful assumptions based upon convention, which means you can do more by writing less code.

Top 10 Free Java Courses for Beginners and Experienced Programmers

The Internet is full of useful resources and no matter what you want to learn there is something useful available for free. You just need to commit your time and effort. But at the same time, it's difficult to choose in the huge sea of free tutorials and courses on the internet. If you are not careful, you will spend most of your time browsing and changing courses without learning anything. That's where a curated list helps. Curation is my hobby and passion. I love to read books and courses which allows me to curate useful resources and share with you guys.

How to work with Files and Directories in Java

The File API is one of the important parts of any programming language or API and even though Java's file API both new and old, are powerful, they are not intuitive enough compared to other languages e.g. Python. Apart from knowing the essential classes and abstractions e.g. File, InputStream, OutputStream, Reader, Writer, Channel etc, you also need to know and remember some nitty gritty detail to avoid subtle issues. There are many articles out there on the internet which can teach you how to read and write data from the file but there are very few which will tell you to do it in right way.

How to implement Radix Sort in Java - Algorithm Example

The radix sort, like counting sort and bucket sort, is an integer based algorithm (i.e. the values of the input array are assumed to be integers). Hence radix sort is among the fastest sorting algorithms around, in theory. It is also one of the few O(n) sorting algorithm along with a bucket and counting sort. The particular distinction for radix sort is that it creates a bucket for each cipher (i.e. digit); as such, similar to bucket sort, each bucket in radix sort must be a growable list that may admit different keys.

Top 5 Free R Programming Courses for Data Scientists and ML Programmers

More and more people are learning R programming language to become a Data Scientist, one of the hottest and high paying technical jobs on the planet. Though, I am from Python camp when it comes on choosing between Python and R for Data Science, Machine Learning, and Artificial Intelligence, mainly because of the awesome libraries Python offers, I had tried R for a short time. If you are also on the same boat and want to try or learn R programming for Data Science and machine learning purpose and looking for some awesome free courses to start your journey then you can take some ideas from this article.

How to convert primitive int value to a Long object in Java?

Suppose you have an int variable but the part of the application is expecting a Long object, how do you convert a primitive int to a Long object in Java? It shouldn't be a problem, right? after all long is a bigger data type than int, so all int values are acceptable as long, but we also need a Long object, not just the long primitive value. Now, the problem is reduced to converting a long primitive to Long object, which is not really a problem if you are running on JRE version higher than Java 5. But, sometimes autoboxing is not efficient e.g. when you have to convert multiple long values into the Long object in a loop. A better way to convert your long primitive to the Long object is by using static factory methods like Long.valueOf(long l), which was originally meant to convert long primitive values to a Long object, prior to Java 5, but, also works fine with int primitive.

5 Free Object-Oriented Programming Online Courses for Programmers

The OOP or Object Oriented Programming is a paradigm which allows you to write a program by modeling real-world things in terms of class and object. It not only make to represent a real-world thing in programming world easier but also allow you to manage the complexity of your program. Even though there are several programming paradigms e.g. procedural and functional, most of the code we write today is object-oriented and some of the most of popular programming languages are object-oriented e.g. Java, Python, PHP, and JavaScript all supported object-oriented programming.

Difference between OCAJP7 and OCAJP8 Certification - 1Z0-803 vs 1Z0-809

One of the frequently asked questions asked by most of the OCAJP certification candidates is, what are the differences between OCAJP 8 and OCAJP 7? And,  Which one Java developers should go for in 2018? OCAJP7 or OCAJP8? The obvious answer to this question is the latest Java version of the exam i.e. OCAJP 8. Since it's already more than 5 months since Java 9 is out but there is no OCAJP 9 certification, the OCAJP 8 should be the exam, Java developer should pursue in 2018. The question is more for those who are looking to become certified Java developer in quick time and doesn't know Java 8 yet e.g. experienced Java developers who have extensively worked in Java SE 6 and prior version but don't have any Java certification yet.

Java 8 Stream findFirst() and filter() Example

Suppose, you have a list of prime numbers and you need to find the first prime number which is greater than a given number? How do you find it? Don't tell that you will loop through the list and check each element and return the first element which is greater than the given number. Well, that's right but that's not what you should do in Java 8. That's good for Java 7 or earlier version but Java 8 offers you many better alternatives and one of them is Stream. You can use the Stream class along with filter() and findFirst() methods to find out an element based upon a Predicate, a functional interface for defining a condition which returns a boolean.

Top 5 Amazon Web Services or AWS Courses to Learn Online - FREE and Best of Lot

Hello guys, if you want to learn Amazon Web Services, popularly known as AWS and looking for some awesome resources e.g. books, courses, and tutorials then you have come to the right place. In this article, I am going to share some of the best Amazon Web Services or AWS courses which will help you to learn this revolutionary and valuable technology free of cost. Unlike other paid courses, these are genuine free AWS courses which are made free by their authors and instructors for the promotional and educational purpose. You just need to enroll with them and then you can learn AWS at any time, at any place and on your own schedule. But, if you are completely new to AWS domain or Cloud let me give you a brief overview of Amazon Web Services and its benefits over traditional infrastructure setup.

Top 5 Free Courses to Learn Web Development in 2018 - Best of Lot

Hello guys, I have been sharing a lot of free online courses and books on various technology and programming language e.g, Python, Java, C++, JavaScript, PHPReact, Angular, Spring in this blog from quite some time and today I have brought some great free courses to learn basics of web development. Web Development is an important skill for programmers in this era of Startups. As a programmer or software developer, you should know how to create a website and how to create a mobile app of your own. Though it's not easy. Coding is like art and many people born with coding sense, I mean they love coding, they love to create stuff e.g. websites, mobile apps, games etc and they love to automate things. They are a very good self-learner and almost learn anything by themselves, but don't get discouraged if you don't have those skills. By perseverance and hard work, you can also learn whatever you want. In the past, I have shared some tips to learn a new technology and books and courses are an integral part of it.

Top 15 Spring Boot Interview Questions with Answers for Java/JEE Programmers

Hello guys, if you are preparing for your next Java interview and Job description mentioned about Spring framework, then you should also prepare some Spring Boot interview questions to avoid disappointment. The Spring Boot is now the standard way to use Spring framework for Java development and almost all the companies are moving from the traditional way of using Spring Framework to more modern Spring Boot way. Gone are the days, where questions like have you used Spring Boot was asked to the developer. Nowadays interview expects more knowledge of Spring Boot from candidates and there are reasons for it, which we'll explore in this article.

21 Websites to Learn How to Code for Free Online

Hello there, if you are someone who is learning programming and coding by yourself and looking for some awesome resources then you have come to the right place. In this article, I am going to share 25 websites you can use to learn the code for free from the comfort of your office and home.

1. plurasight.com
One of the best website to learn any technology or IT courses e.g. programming language like Java, web development framework e.g. Spring Framework, Hibernate etc. It's also now acquired CodeSchool which earlier allows you to learn web technologies by doing it. I use this website to learn a lot of cool stuff in no time.

Top 20 Essential Java Interview Questions with Answers for Freshers with 1 to 2 years Experienced

If you are grad looking for an internship position in a company which uses Java, or a fresher, just out from college and looking out for Java development position, then this post is for you. I have attended, taken and participated in a different level of Java interviews, and I can say there is a huge difference between them, which is not surprising because you obviously want to ask different level questions based upon whether the candidate is fresher or experienced. Similarly, the question at phone interview, written test, and face to face interviews, keeping this in mind, and give you always have a limited amount of time before going for an interview, It's important to prepare right set of questions.

Binary tree InOrder traversal in Java using Recursion

The InOrder traversal is one of the three popular ways to traverse a binary tree data structure, other two being the preOrder and postOrder. During the in order traversal algorithm, left subtree is explored first, followed by root, and finally nodes on right subtree. You start traversal from root then goes to left node, then again goes to left node until you reach a leaf node. At that point in time, you print the value of the node or mark it visited and moves to right subtree. Continuing the same algorithm until all nodes of the binary tree are visited. The InOrder traversal is also known as left-node-right or left-root-right traversal or LNR traversal algorithm.

5 Free HTML and CSS Courses to Learn Front End Web Development Online

HTML and CSS are two pillars of web development, they are used to create web pages you see every day. HTML provides the structure to your web page and CSS provides them the style to look better. If you want to become a front-end web developer or web designer then a good knowledge of HTML and CSS is a must. Even though modern day web development is all about framework and library e.g. Angular and React, you still need to know HTML and CSS to understand what's going on and troubleshoot any issue you face while developing a web application. Btw, JavaScript is another pillar of web development but we'll not discuss on this article. I have already shared some good books to learn JavaScript before

How to Rotate an Array to Left and Right by Given Number in Java? - Coding Program with Solution

Hello guys, welcome to this post with another array based coding problem. In the last article, we've learned about finding missing numbers in the array with duplicates and today we'll solve the problem of rotating an array by left or right by given number. For example, suppose an integer array {1, 2, 3} is given and it was asked to rate this array to the left by 3 then the result array will look like {2, 3, 1} because it was rotated twice on left. Similarly if asked to rotate the same array twice by right then we'll get {1, 2, 3}, the same array is back. This is an interesting problem and it's quite easy to solve but I have many programmers struggles with this one as well. So, a little bit of practice and learning will not hurt.

Top 35 Java String Interview Questions with Answers

The  String class and concept is a very important class in Java. There is not a single Java program out there which is not using String objects and that's why it's very important from interview point of view as well. In this article, I am going to share 35 String based questions from different Java interviews. It includes questions on java.lang.String class as well as string as data structure e.g. some coding questions something like I have shared in my earlier article about 75 Coding questions to Crack any Programming Job interviews.  You can use this list to refresh your knowledge about String in Java as well as to prepare for your next Java interview. If you have any good String questions which are not on this list, feel free to drop a note and I'll include in this list.

Eclipse IDE - How to Remote Debug a Java Application Running on Linux

The remote debugging of Java program is an ultimate tool in the arsenal of a Java developer, which is often become the last and only tool to investigate a bug on a Java application running on remote host e.g. on Linux server or Windows server. Almost all major Java IDE provides remote debugging e.g. NetBeans, Eclipse, and IntelliJ IDEA, but I mostly use Eclipse for Java coding and so it's my preferred tool to remote debug a Java program. In order to setup remote debugging in Eclipse, you need to do a couple of tasks e.g. you need to start your JVM with debugging parameters or arguments and then you need to create a "remote debug configuration" in Eclipse IDE itself.

5 Free Eclipse and JUnit Online Courses for Java Developers

Eclipse and JUnit are two of the essential tools for Java Developers. Eclipse is a Java IDE, Integrated Development environment which allows you to code, run and debug Java program from a single window, while JUnit is a unit testing library which allows you to test your Java code automatically. You can write JUnit tests and then you can run them automatically using Maven or Gradle plugin at build time. You can further automate your build using Jenkins which means your Unit test will run continuously and automatically, reporting any break at the earlier possible opportunity.

What is double colon (::) operator in Java 8 - Example

The double colon (::) operator is known as the method reference in Java 8. Method references are expressions which have the same treatment as a lambda expression, but instead of providing a lambda body, they refer to an existing method by name. For example, to print all elements of the list you can use the forEach() method as follows

list.stream.forEach( s-> System.out.println(s));

but here you can replace lambda expression with method reference to improve readability as shown below:

list.stream.forEach( System.out::println);

You can use method reference or double colon operator to refer a static method, an instance method, or a constructor.

How to remove duplicates from Stream in Java 8 - Stream.distinct() Example

You can use the Stream.distinct() method to remove duplicates from a Stream in Java 8 and beyond. The distinct() method behaves like distinct clause of SQL which removes duplicate rows from the result set. The distinct() is also an intermediate method which means it will return a new Stream without duplicates, which can be used for further processing. Like other methods of Stream class e.g. map() or filter(), distinct() is also lazy and it will not remove duplicate elements until you call a terminal method on Stream.  The actual processing of Stream pipeline starts only after calling terminal methods like collect() or forEach().

Top 5 Books to Learn Grails Framework for Java and Groovy Developers.

Earlier, I have shared some of the must-read Groovy books and today, I'll share some of the best books to learn Grails for Java developers. Grails is a web application development framework completely written in Groovy. The Grails and Gradle framework are built using Groovy language. Grails is the framework to develop a web application using Groovy. The concepts within Grails, like interceptors, tag libs, and Groovy Server Pages (GSP) are very similar to what we have in Java. You'll be amazed at how quickly you can have a first-class web application up and running from ground zero. Grails includes everything you need in a single zip file on a web server (Jetty), a database (HSQLDB), Spring, Hibernate, even a Groovy version of Ant called GANT.