HTML

Difference between 32-bit vs 64-bit JVM in Java?

Hello guys, wish you a very happy new year 2020. I hope you have set all your goals and inspired to achieve them. I have written some articles to help with your goals like The 2020 Java Developer RoadMap and 10 Things Java Programmer Should Learn in 2020. If you haven't made your goals or want to find out some useful resources to achieve your goals you can check out that article. Coming back to this article, it's short but informative one and it's also one of the most asked questions to me on Facebook and LinkedIn, what is the difference between a 32-bit and 64-bit JVM? While most of the servers now running on 64-bit JVM and its rare to find server-side applications still running on 32-bit JVM, the question may not be relevant in 2020 but it is still something useful to learn and know.

Difference between StringTokenizer and Split method in Java?

There are multiple ways to split a String in Java, but two of the most common ways are by using StringTokenizer and split method of String class. You can use either one of them, but when to use which one? This short article will give you some details about StringTokenizer and Split method in Java to decide which one to use.

1) The StringTokenizer is legacy, Prefer split() as more chances of its performance getting improved as happens in Java 7.

2) The StringTokenizer doesn't support regular expression, while spilt() does. However, you need to be careful, because every time you call split, it creates a new Pattern object and compiles expression into a pattern. This means if you are using the same pattern with different input, then consider using Pattern.split() method, because compiling a pattern takes more time later to check whether a given string matches a pattern or not.

How to convert a Map to List in Java 8 - Example Tutorial

When you convert a Map to List in Java 8 or before, you have three choices, like you can get a list of keys from Map, List of values from Map, or a List of entries from Map, which encapsulates both key and value. The API doesn't provide these methods because Map doesn't guarantee any order and List interface guarantee ordering, i.e. insertion order. Hence, JDK API provides an equivalent method to convert a Map to Set, like keySet() will return a set of keys and entrySet() will return a set of entries. Since Set cannot have duplicates and Map also cannot have duplicate keys, the Set data structure seems to perfect for returning keys and entries.

5 Things You can Gift to Programmers,Software Developers and Tech Geeks

So, its that time of the year again when you start thinking about gifts for your programmer boyfriend, husband, colleagues, or your near dear ones. Even if selecting presents or gifts were not tough, if your friend happened to be a programmer, it becomes slightly tougher. You might have heard that Programmers are aloof, nerd, and tech freaks, well, you heard it right. Programmers prefer to be alone in their own world, but they also like gifts, and you got it right; they are a nerd, so they love books, gadgets, music, and something which helps them to learn something, like a Udemy, Educative, or PluralSight membership.

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

Top 21 String Programming and Coding Interview Questions With Solutions

In this article, I am going to share 21 of the most common String-based Programming and Coding interview questions from Java developer interviews. These questions require you to write code to solve the problem and they are different from traditional Java String questions like how substring method works in Java or when to use the intern() method of String in Java? Since coding and problem solving are an important part of any programming job interview, it's imperative that you know how to solve them in time and on a pressure situation, which comes only after doing practice with the right set of questions. Since these questions are already tried and tested and appeared in many interviews, they will provide you the experience you need to crack your coding interview.

What is Overloading, Overriding, Hiding, Shadowing and Obscuring in Java and Object-Oriented Programming?

Hello guys, today, I am going to explain a couple of fundamental object-oriented programing concepts in Java like Overloading, Overriding, Hiding, Shadowing, and Obscuring. The first two are used in the context of a method in Java while the last three are used in the context of variables in Java. Two methods with the same name and same class but the different signature is known as overloading and the method is known as an overloaded method while a method with same name and same signature but in parent and child class is known as overriding. On the other hand,  Hiding is related to overriding since the static and private method cannot be overridden, if you declare such methods with same name and signature in parent and child class then the method in child class will hide the method in the parent class.

Difference between POST and GET Request in HTTP Protocol

HTTP Protocol supports many methods to retrieve data from the server or perform any operation on the server, e.g. upload data, delete the file, etc. In total, the HTTP protocol supports the following methods, e.g. GET, POST, PUT, DELETE, HEAD, DELETE, OPTIONS, and TRACE, and HTTP 1.1 reserves technique called CONNECT for future use.  GET, and POST is two of the most common HTTP methods you would hear or work on the web. Though both can be used to send and receive data from client to server, there are some crucial differences between the GET and POST in HTTP, which will help you to understand when you should use GET vs. POST while writing your client and server application.

10 Examples to Format and Parse Date Time in Java 8 using LocalDateTime and DateTimeFormatter

Parsing and formatting dates are other essential topics while working with date and time in Java. Even though old Date API had SimpleDateFormat and DateFormate class to support formatting of date and parsing texts, they were not simple, or should I say there were just simple in writing wrong code. You might know that SimpleDateFormat was not thread-safe and quite heavy to be used as a local variable. Thankfully, this has been sorted now with a new LocalDateTime class and DateTimeFormatter class, which has several inbuilt formatter, like BASIC_ISO_DATE format, which prints dates in yyyyMMdd format, like 20160616 and ISO_DATE which prints date as yyyy-MM-dd, like 2016-06-16. It has several useful formats to represent popular date formats around the world, like the date format used in the USA is different from than date format used in the UK and India.

How to convert ArrayList to HashMap or LinkedHashMap in Java 8 - Example Tutorial

One of the common tasks in Java is to convert a List of objects, like a List<T> into a Map, I mean Map<K, V>, where K is some property of the object and V is the actual object. For example, suppose you have a List<Order>, and you want to convert it into a Map, e.g. Map<OrderId, Order>, how do you that? Well, the simplest way to achieve this is iterating over List and add each element to the Map by extracting keys and using the actual element as an object. This is exactly many of us do it in pre-Java 8 world, but JDK 8 has made it even simpler. In Java 8, you can get the stream from List and then collect all elements into a Map by using a Collector. The collect() method of Stream class and java.util.stream.Collectors class gives you ample choices to decide which property goes into the key and which object goes into the value.

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.

3 ways to find Repeating number in given array in Java?

Problem: You have given an int array that contains duplicate or repeating elements like numbers. You need to find all those repeating numbers from a given array. Remember, the array may contain 1, 2 or multiple duplicates. You need to print all of them. For example, if the given array is {1, 2, 3, 4, 5, 6, 1} then your program should print 1. Similarly, if the given array is {3, 3, 2, 2, 4} then your solution should return 2 and 3, the order is not important as long as you can identify all the repeating elements.

When to use PUT or POST in a RESTful Web Service?

One of the most common confusion among web developers is the choice of PUT or POST HTTP method for creating or updating a resource while developing RESTful Web Services. Since both can be used to submit data, you can use either POST or PUT to create or update a resource. Many web developers want to use PUT for creating a resource on the server because it's idempotent. No matter how many times you call the PUT, the state of the resource will not jeopardize. Since the possibility of re-submission is real on a slow network, using PUT to create resource makes it easy, as you don't need to worry about user clicking the submit button multiple times.

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 a distinct clause of SQL, which eliminates duplicate rows from the result set. The distinct() is also a standard method, which means it will return a new Stream without duplicates, which can be used for further processing. Like other methods of Stream class, like 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().

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

Even though the Java library has a power function, Math.pow(), to calculate the power of a given number in Java, it's a regular programming exercise for Java programmers 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 binary value, but you are allowed to use just integer, but beware that power function may overflow.

10 Examples of Stream in Java 8 - count + filter + map + distinct + collect

The Java 8 release of Java Programming language was a game-changer version. It not only provided some useful method but totally changed the way you write programs in Java. The most significant change it brings in the mindset of Java developers was to think functional and supported that by providing critical features like lambda expression and Stream API, which takes advantage of parallel processing and functional operations like filter, map, flatMap, etc. Since then, a lot of Java developers are trying their hands to learn those significant changes like lambda expression, method reference, new Date and Time classes, and, more importantly, Stream API for bulk data operations.

13 Free Java 8 Certification Sample Questions - OCAJP8 and OCPJP8 - 1Z0-808 and 1Z09 dumps

Hello guys, Java SE 11 certifications are already out but not many people are going for it because of difficulty level. If you want to become a certified Java developer then Java SE 8 is still the best possible option. If you are preparing for Oracle Java SE 8 Certifications, like OCAJP8 and OCJP8, also known as exam 1Z0-808 and 1Z0-809 and looking for some free practice tests, then you have come to the right place. In this article, I am going to share some of the best OCAJP 8 and OCPJP 8 mock tests available for free of cost online, so that you can check your speed and accuracy before the real exam. These tests are not just useful for Oracle's Java OCA and OCP certification but also for upgrade exams like OCJP 8 upgrade exams with code 1Z0-810 and 1Z0-813, upgrade to Java SE 8 from Java 6 and prior version.

Java 8 Map Function Examples

The map is a well known functional programming concept which is incorporated into Java 8. Map is a function defined in java.util.stream.Streams class, which is used to transform each element of the stream by applying a function to each element. Because of this property, you can use map() in Java 8 to transform a Collection, List, Set or Map. For example, if you have a list of String and you want to convert all of them into upper case, how will you do this? Prior to Java 8, there is no function to do this. You had to iterate through List using a for loop or foreach loop and transform each element. In Java 8, you get the stream, which allows you to apply many functional programming operators like the map, reduce, and filter.

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 reverse a singly linked list in Java without recursion? Iterative Solution

Hello guys, reverse a linked list is a common coding problem from Programming Job interviews and I am sure you have seen this in your career, if you are not, maybe you are a fresher and you will going to find about this very soon in your next technical interview. In the last article, I have shown you how to use recursion to reverse a linked list and today, I'll show you how to reverse a singly linked list in Java without recursion. A singly linked list, also known as just linked list is a collection of nodes which can only be traversed in one direction like in the forward direction from head to tail. Each node in the linked list contains two things, a data and a pointer to the next node in the list.

3 Ways to convert java.util.Date to java.time.LocalDate in Java 8 - Example, Tutorial

One of the great features of Java 8 is the new Date and Time API which is intended to fix existing issues related to mutability and thread-safety with existing java.util.Date class. But given java.util.Date is used very heavily across all the Java application, you will often end up with a situation where you need to convert java.uti.Date to java.time.LocalDate while working in Java 8. Unfortunately there is no toLocalDate() method in the java.util.Date class. Though, you can easily convert Date to LocalDate if you are familiar with how new and old API classes map to each other.

What is difference between final vs finally and finalize in Java?

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 purposes. 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 like String is final in Java. When you use the final modifier with a method, then 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, it finally is a keyword related to exception handling in Java. It's often used with a try block, and it's part of try, catch, and finally trio.

How to Convert String to LocalDateTime in Java 8 - Example Tutorial

Hello guys, today, I will talk about a common problem while working in a Java application, yes you guessed it right, I am talking about String to Date conversion in Java. I had discussed this before (see the Date to String) when Java 8 was not out, but with Java 8, I don't see any reason to use old date and time API, and hence I am writing this post to teach you how to convert String to Date in Java 8 or beyond. Suppose you have a date-time String "2016-03-04: 11:01:20" and you want to convert this into a LocalDateTime object of Java 8 new date and time API, how do you do that? Well, if you have worked previously with String and Date then you know that you can parse String to Date in Java.

Deep Dive into float and double data types in Java

Hello All, float and double are two fo the important data types in Java, but many developers don't pay enough attention to these two data types, resulting in writing poor code with subtle bugs. To be honest, they are not easy to use because of the complexity with floating-point calculation but knowing even simple things like the maximum, and minimum limit of float and double data types and how to compare float and double variables can go a long way in eliminating bugs which are not obvious. All this information is available on Java documentation and books and courses I have shared earlier, but by writing this article, I am bringing all this information in one place, which will help you to learn and remember them better.

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 the top level if it is not inside any other class, and a class that is inside another class is known as nested class. You can create a nested class inside another top-level or another nested class in Java. This is the class that can be static in Java.

Is it Possible to Create Object or Instance of an Abstract class in Java?

Hello guys, how are you doing? Hope you are doing well. It's been long since  I shared a core Java interview question in this blog, so let's start with that. Earlier I have shared one of the frequently asked questions in Java, can we make an abstract class final in Java and my readers really liked and asked for more such questions. So, today I am going to talk about whether you can create an instance of an Abstract class in Java or not? This is another interesting core Java question that you will find on telephonic interviews, a written test that has multiple-choice questions and most notably Oracle certified Java programmer certification like OCAJP 8  and OCAJP 11.

How to read a CSV file with Header in Java using Jackson library - Example Tutorial

Hello guys, today I am going to show you how to read a CSV file in Java with a simple example of Jackson API. For a long time, I only knew that Jackson can be used to parse JSON but later realized that you can also use it to parse or read CSV file in Java. The Jackson DataFormat CSV library allows you to read a CSV file in just a couple of line and its really powerful and feature rich. For example, you can read a CSV file with a header or without a header. You can even read a tab-delimited text file like CSV. It's also highly configurable and allows you to define columns separator to read a text file with any delimiter. You can even use it to directly convert the CSV data into Java objects, just like we do while reading JSON String in Java.

Learn Tree Data Structure in 5 Minutes - Binary Tree (BT), Binary Search Tree (BST), and Balanced Tree (AVL vs Red Black)

The Tree data structure is one of the essential data structures, but unfortunately, many programmers don't pay enough attention to learning Trees, particularly advanced tree data structures like balanced trees like AVL and Red-Black tree. Many of them think that knowing just array and the linked list is enough for programming interviews, but when they face questions about a tree, like the difference between binary tree and binary search tree, or difference between binary search tree and a self-balanced tree-like AVL tree or Red-Black tree, they become speechless.

The Right way to Remove Objects while Iterating over ArrayList in Java - Example Tutorial

One of the common problems many Java Programmers face is to remove elements while iterating over ArrayList in Java because the intuitive solution doesn't work, e.g., you just cannot go through an ArrayList using a for loop and remove an element depending upon some condition. Even though java.util.ArrayList provides the remove() methods, e.g. remove (int index) and remove (Object element), you cannot use them to remove items while iterating over ArrayList in Java because they will throw ConcurrentModificationException if called during iteration. The right way to remove objects from ArrayList while iterating over it is by using the Iterator's remove() method.

What is difference between Heap and Stack Memory in Java JVM

One of the many traits of a good programmer is how well he understands the fundamental and if you want to check the fundamentals of Java programmer than asking the difference between heap and stack memory is a good choice. Even though both are part of JVM and both consumers memory allocated to the Java process, there are many differences between them e.g. Heap memory is shared by all threads of Java application but Stack memory is local to each thread. Objects are created in heap memory but method frames are stored in Stack memory, and size of heap space is much bigger than the small size of Stack in Java. Even if you know this much information about heap and stack in Java, you are one of the better candidates, but let's see some more details to impress the interviewer.

Difference between the getRequestDispatcher and getNamedDispatcher in ServletContext?

The ServletContext class provides two methods getRequestDispatcher(String url-pattern) and getNamedDispatcher(String name), which can be used to dispatch a request to a particular servlet. The main difference between getRequestDispatcher() and getNamedDispatcher() method is that former accepts a URL pattern or path while later agrees with a Servlet name defined in deployment descriptor or web.xml file, both return an instance of RequestDispatcher class, which can further use to forward or redirect a request in Java web application. Let' see some more detail about these two methods and how they work.

How to Reverse an Array in place - Java Coding Problems with Solution

It's relatively easy to reverse an array if you have the luxury to use another array, but how would you reverse an array if a temporary buffer is not allowed? This is one of the testing array interview questions, which often proved tricky for Java and other beginner Programmers. But, don't worry, I'll tell you how you can solve this problem without losing your cool. Well, you can also reverse an array in place without using an additional buffer. If you know how to access array elements and how to loop over an array in Java using traditional for loop, you can easily solve this problem without using additional space or in-place as described in many Algorithms books and courses, and on Coding interviews.

How to make a new array in Java?

There are several ways to create an array in Java, for example, you can declare the array without initializing it, or you can create and initialize the array in the same line. If you want to make an array with values, then you need to first decide which type of array you want to create? e.g., do you want String array, which can contain String objects like "abc," "def," or do you want to create an int array which contains int values like 10, 20, etc. In Java, you can create an array of any type, including both primitives like byte, int, long and objects like String, Integer, and other user-defined objects. Let's some code to make a new array in Java.

10 Free Java Programing Books for beginners - download, pdf and HTML

Every Java programmer loves free eBooks on Java, don't you? When I shared my collection of top 10 Java programming books, one of my readers asked me to share some free Java books as well. Doing a quick search on the internet reveals lots of free books, resource, and tutorials to learn Java. I have chosen some of the good Java books, which are FREE, available for download or you can read it online in HTML or PDF format. These books are an excellent resource for any Java beginners, as well as an experienced programmer, and since they are free, it makes absolute sense to have a look on this before buying any other book in Java.

3 ways to ignore null fields while converting Java object to JSON using Jackson

Ignoring null fields or attribute is a one of the common requirement while marshaling Java object to JSON string because Jackson just prints null when a reference filed is null, which you may not want. For example, if you have a Java object which has a String field whose value is null when you convert this object to Json, you will see null in front of that. In order to better control JSON output, you can ignore null fields, and Jackson provides a couple of options to do that. You can ignore null fields at the class level by using @JsonInclude(Include.NON_NULL) to only include non-null fields, thus excluding any attribute whose value is null.

QuickSort Algorithm Example in Java using Recursion - Sorting Algorithm Implementation

The Quicksort algorithm is one of the very popular sorting algorithms in programming, often used to sort a large array of numbers. Though there is numerous algorithm available to sort a list of objects, including integer, string and floating point number, quicksort is best for general purpose. It's a divide and conquers algorithm, where we divide the given array with respect to a particular element, known as 'pivot' such that the lower partition of the array are less than the pivot and upper partition elements of the array are higher than the pivot. The Quicksort is also one of the best examples of recursion, a key programming technique to solve Algorithmic problems. This algorithm is naturally recursive because it sorts the large list by dividing into smaller sub-list and then applying the same algorithm on those.

How to Remove an Element from Array in Java with Example

There is no direct way to remove elements from an Array in Java. Though Array in Java objects, it doesn't provide any methods to add(), remove() or search an element in Array. This is the reason Collection classes like ArrayList and HashSet are very popular. Thanks to Apache Commons Utils, You can use there ArrayUtils class to remove an element from array more easily than by doing it yourself. One thing to remember is that Arrays are fixed size in Java, once you create an array you can not change their size, which means removing or deleting an item doesn't reduce the size of the array. This is, in fact, the main difference between Array and ArrayList in Java.

How to combine two Map in Java? Example Tutorial

You can combine two maps in Java by using the putAll() method of java.util.Map interface. This method copies all the mappings from one Map to another, like, if you call it like first.putAll(second), then all mappings from the second Map will be copied into the first Map. Which means if the first map contains 5 elements and the second map contains 10 elements or mapping, then the combined map will contain 15 or fewer mappings. In the case of duplicate keys, the value is overridden or updated from the second map. For example, if the first map has a mapping 1 -> One and second map has mapping 1 -> ONE then after combining the second map into the first one, the value of 1 will be ONE, i.e. the value from the second map.

Top 5 Java EE Bad Practices Java Developers should Avoid

Here are some of the bad coding practices you should avoid while working for a Java EE application or Java Web application in general, which runs on a Web Server like Tomcat or Enterprise Server like JBoss, WebLogic, or IBM WebSphere:

1) Calling System.exit() from a Web application
It is never a good idea for a web application to attempt to shut down the application container. A call to System.exit() is probably part of leftover debug code or code imported from a non-J2EE application. You can further read my article "Don't use System.exit() on Java web application" to learn more about.

Difference between first level and second level cache in Hibernate

The main difference between first level and second level cache in Hibernate is that the first level is maintained at the Session level and accessible only to the Session, while the second level cache is maintained at the SessionFactory level and available to all Sessions. This means, you can use the first level cache to store local data, i.e. the data which is needed by the Session, and you can use the second-level cache to store global data, i.e. something which can be shared across sessions. This is also one of the frequently asked Hibernate Interview questions and accessible in both telephonic rounds as well as on face to face interview, in both fresher and experienced level interviews.

Difference between a List and ArrayList Reference Variable in Java?

Someone who is just starting with Java programming language often has doubt about how we are storing an ArrayList object in List variable, what is the difference between List and ArrayList? Or why not just save the ArrayList object in ArrayList variable just like we do for String, int, and other data types. Well, the main difference between List and ArrayList is that List is an interface while ArrayList is a class. Most importantly, it implements the List interface, which also means that ArrayList is a subtype of List interface. In Java or any object-oriented language, supertype of a variable can store an object of subtype.

How to use Queue Collection in Java? An example Tutorial

The JDK provides an implementation of several data structure in Java collection framework, e.g., ArrayList is a dynamic array, LinkedList represents a linked list, HashMap represents a hash table data structure, and Queue interface represent queue data structure. Btw, If you are not familiar with data structure itself, then you can also see Introduction to Data Structures & Algorithms in Java, an excellent course to start with the essential data structure in Java. The Queue data structure allows you to process elements in the first in first out order, and that's why it is also known as a FIFO data structure. In order to provide first in primary out functionality, it allows you to insert data at one end and delete data from other ends, also known as consuming data. If you need to process objects in the FIFO order, you can use a Queue to store them.

How to write a Generic method in Java

A method is called generic method if you can pass any type of parameter to it and it will function the same e.g. it allows the same logic to be applied to different types. It's known as a type-safe method as well.


1) You can declare Generic methods not only on Generic or parameterized class but also on regular classes which not generic.

2) The type declaration like <T> should come after modifiers like public static but before return type like the void, int, or float. Here is an example of a generic or parameterized method declaration

public static <T> void swap(T a, T b){

}

Eclipse Netbeans Keyboard Shortcut Mapping for Java programmer

If you are a Java developer who has been using Eclipse for Java development, but you need to use Netbeans for your current project due to various reason,, then this article is for you. Whenever we transition between tools, we need the equivalent of one into other. For example, if you are Eclipse power user who is used to Ctrl + Shift + R and Ctrl + Shift + T then as soon as you start using Netbeans, you miss those shortcut. One thing to keep your productivity up is to quickly find the equivalent shortcut in a new tool, e.g., in Netbeans if you are switching from Eclipse or vice-versa. In this article, I am going to share the Netbeans equivalent of 10 useful Eclipse shortcuts for Java developers. You will benefit if you have to use any of these IDEs.

Difference between Correlated Subquery and Self-contained (non-correlated) subquery in SQL

Hello guys, today, I am going to talk about one of the common SQL concepts of subqueries, a query inside another query. There are two types of subqueries in SQL, correlated subquery and self-contained subquery, also known as nested, non-correlated, uncorrelated or simply a subquery. The main difference between them is, self-contained subqueries are independent of the outer query, whereas correlated subquery has a reference to an element from the table in the outer query. In other words, In the case of the nested subquery, both primary and subquery can run independently. But, in the case of the correlated subquery, you can not run them individually because subquery refers to rows from the outer query.

How to make HTTP Request from a 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.

Can you add a non-abstract method on an interface in Java?

Well, prior to Java 8, it wasn't possible to add non-abstract methods in Java but nowadays you can add non-abstract static, default, and private methods in Java interface. The static and default methods were supported as part of interface evolution in Java 8 and you can add private methods on an interface from Java 9 onwards. Since long, many Java programmers feel that there is no real use of an interface, well that's completely wrong, given how interface allows you to write generic, decoupled code, most of those sentiments comes from no implementation on the interface.

How to use PreparedStatement in JDBC Java? An Example

PreparedStatement is used to execute specific queries which are supposed to run repeatedly, for example, SELECT * from Employees WHERE EMP_ID=?. This query can be run multiple times to fetch details of different employees. If you use PreparedStatement like above than database assist in query preparation, which is faster and more secure. Such kind of queries are compiled, and their query plans are cached at database side to every time you execute it, you will get a faster response as opposed to using simple queries via Statement object, like SELECT * from Employees WHERE EMP_ID + emp_id.

15 People Java Developers Should Follow on Twitter

If you are passionate about Java and would like to follow Java bloggers into Twitter then here is my list of 15 people you can follow on Twitter to keep yourself up-to-date and engage in Java world. These people regularly share the latest things in Java, JVM, Spring, Hibernate, and other Java technology. By following them, you will not only know about their latest work but also what's happening in Java world. You might be thinking just 15 people, well, there are many more which is not in this list but I regularly share their twitter handles via my twitter account @javinpaul and @Javarevisited. If you are following me then you will automatically get to know about them.

How to solve Arithmetic overflow error converting IDENTITY to data type tinyint, smallint or int in Microsoft SQL Server database

Last year we had a production issue where one of our backup jobs was failing while inserting Orders aggregated from other systems into our SQL Server database. The reason was dreaded "Arithmetic overflow error converting IDENTITY to data type int" because the table was using IDENTITY feature of SQL Server to generate OrderId, and Identity has breached it a maximum value, which is around 2.1 billion, precisely 2,147,483,647. The error "Arithmetic overflow error converting IDENTITY to data type int" comes when IDENTITY value is inserted into a column of data type int, but the value is out-of-range. For example, if the current value of Identity becomes more than 2,147,483,647, then you cannot store that into an int column because it's more than the maximum value of int in SQL Server.

50+ Microsoft SQL Server Phone Interview Questions and Answers

Are you preparing for an SQL Server Interview? or, a Java developer position where SQL Server skills are important? If yes, then here are a couple of frequently asked Microsoft SQL Server Interview questions you should practice before going for your interview. These questions are also good to brush-up your Database and SQL fundamentals which is always asked as part of interviews.These list contains not only godo SQL Server interview questions but also some basic SQL questiosn which you will see everywhere. The list is useful for both beginners and intermediate develoeprs and DBAs with 0 to 2 years of exeprience.

1. What is normalization? (answer)
Normalization is processed to reduce duplication from tables. They help to reduce storage space by removing duplicate but after a certain normal form, it also makes difficult to query data. A table should at least be in 3rd normal form for all practical purpose.

How Binary Search Algorithm Works - Java Example Without Recursion

The binary search algorithm is one of the fundamental Computer Science Algorithms and used to search an element in a sorted input set. It's much faster than the linear search which scans each and every element and improves performance from O(n) to O(logN) for searching an element in the array. In order to perform the binary search, you need a sorted array, so you can either ask the user to enter array in sorted order or you should sort the array before performing the binary search. It's also one of the popular algorithms on Programming Job interviews. Interviewer often asks candidates to implement binary search algorithm by hand in their favorite programming languages like Java, C++, Python. or JavaScript.

How to Prepare for Java Certifications like OCAJP, OCPJP, or OCEJWCD?

No doubt that Oracle's Java certification is one of the most valuable certifications for IT industry and helps you to get a better job, better pay, and a better rise in your current salary. It also improves your recognition and job prospects because many big clients demands certified Java programmers for their mission-critical applications. Because of enormous popularity and usefulness, many Java developers and computer science graduate aspire for Java certifications. I often receive queries like, what is the best way to prepare for Java certifications like OCAJP or OCPJP? Or I am already coding in Java, do I need to make explicitly for this exam to do well or my Java development experience is enough? I have 5 years of experience in Java, do I need to prepare for OCAJP 8 or OCPJP 8 exam? Etc.

3 ways to create random numbers in a range in Java

Many times 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 programmers, 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.

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.

Grouping By, Partition By, Joining, and Counting in Stream - 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 like 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.

Top 5 Sorting Examples of Comparator and Comparable in Java 8

The JDK 8 release has completely changed the way you compare objects and sort them in Java. The new features of Java 8 language e.g. lambda expression and method reference has made it easier to implement both Comparator and Comparable interface, as you don't need Anonymous class for inline implementation. Now, you can create Comparators in just one line by using lambdas and method reference as we'll see in this article. Other features like providing default and static methods on interfaces have also made a huge difference when it comes to Comparator. They helped Java API designer to redesign and evolve existing interfaces, which wasn't possible earlier without breaking existing clients of those interfaces.

Java String 101 - Everything You Want to Know about String in Java

someone might question that why do we need another article about string in Java, haven't we had enough about the string is already written? Yes, I agree there are a lot of articles related to Java string covering topics like how to use Java String, an example of Java string and almost everything you can do with string in Java. But, I wanted to document my experience of using String in Java and some nasty and little-known things I discovered about the Java String class, which may not be obvious to many Java developers. A string is available in almost every programming language and its probably the most used data structure or a data type, hence a good knowledge of String is very important for every Java developers.

50+ Basic Core Java Interview Questions with Hints and Answers

If you are preparing for your next Core Java interview and looking for some common question to practice or check your knowledge, then you have come to the right place. In this article, I'll share 50 Core Java Interview Questions from various companies. I have already discussed the answers to these questions in this blog or Javarevisited, so I have just put the link. First, you should try to answer it yourself and if you cannot then go to the link and find the answer. You can also compare your answer with mine and learn a few things here and there. In most of my interview post, I have also shared some common techniques to drive interview towards your comfort zone and how to leave a long-lasting impression on the interviewer, you can use those techniques to do well on your Java interviews.

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 traverse, I mean linearly, binary tree has several ways to traverse all nodes because of its hierarchical nature like level order, preorder, postorder and in order. 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 the left node before you come back and traverse the right node.

Top 50 Java Generics and Collection Interview Questions

Java Collection and Generic are a very important topic for Java Interviews. They also present some of the hardest questions to a programmer when it comes to interviews, especially Generics. It's not easy to first understand what a particular piece of code doing with those question mark and other signs and then the pressure of interviews also makes it hard to answer complex usage of Generics.  But, with proper preparation and paying attention to both Java Collection and Generic, you can solve that hurdle. If you are looking for Java job but hasn't done well in the interviews you have given so far then you have come to the right place. In this blog, I have shared a lot of Java interview questions on various topics and difficulty levels.

How to declare and Initialize two dimensional Array in Java with Example

An array of more than one dimension is known as a multi-dimensional array. Two of the most common examples of multi-dimensional arrays are two and three-dimensional array, known as 2D and 3D array, anything above is rare. I have never seen 4-dimensional arrays, even 3D arrays are not that common. Now the question comes when do use a multi-dimensional array? Any real-life example? Well, 2D arrays are very common on platform games like Super Mario Bros to represent screen or terrain; 2D arrays can also be used to represent structures like a spreadsheet, or to draw board games like Chess, which requires 8x8 board, Checkers and  Tic-Tac-Toe, which requires 3 rows and 3 columns.

Difference between OCAJP7, OCAJP8, and OCAJP11 Certification - 1Z0-803 vs 1Z0-808 vs 1Z0-815

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, after Java 11 certification release, what is the difference between OCAJP 11 (1Z0-815) and OCAJP 8 (1Z0-808) Which one Java developers should go for? OCAJP7 or OCAJP8, or OCAJP 11? The obvious answer to this question is the latest Java version of the exam, I mean OCAJP 11. Since it's already more than a couple of months since Java 12 is out but there is no OCAJP 9 certification, the OCAJP 8 should be the exam, Java developer should pursue this year and beyond. The question is more for those who are looking to become certified Java developer in quick time and doesn't know Java 8 yet like experienced Java developers who have extensively worked in Java SE 6 and prior version but don't have any Java certification yet.

Java - Variable and Method Hiding Example

If Java, if you are not careful you can possibly hide both methods and variables of the superclass. A field or variable is said to hide all fields with the same name in superclasses. Similarly, a static method with the same name in a subclass can hide the method of the superclass. This can lead to subtle bugs, especially if you are expecting a different method to be called. In this article, I'll show you examples of both variable and method hiding in Java so that you can understand and avoid them in the future.

How to use Multiple Threads in Java - Example

Hello guys, Multithreading is one of the biggest strength of Java, which allows you to divide a task and execute faster by using more than one threads. In order to use multiple threads in Java, you need to first define the task which will be executed by those threads. In order to create those task, you can either use Runnable or Callable interface. If you are just learning Java chose the Runnable interface, it's simpler one, but if you are familiar with Java multithreading and want to leverage additional features offered by Callable like it can throw an exception and it can also return value, then go ahead and use the Callable interface. Once you have task ready, you need to create an instance of the Thread class.

Post Order Traversal in Java Without Recursion - Example Tutorial

In the last article, I have shown you how to implement post-order traversal in a binary tree using recursion and today I am going to teach you about post order traversal without recursion. To be honest, the iterative algorithm of post-order traversal is the toughest among the iterative pre-order and in-order traversal algorithm. The process of post-order traversal remains the same but the algorithm to achieve that effect is different. Since post-order traversal is a depth-first algorithm, you have to go deep before you go wide. I mean, the left subtree is visited first, followed by right subtree and finally the value of a node is printed. This is the reason why the value of root is printed last in the post-order traversal algorithm.

Can you join two unrelated tables in SQL? Cross Join Example

In one of the recent programming job interview, one of my readers was asked the question, how do you join two tables which are not related to each other? i.e. they don't have any common column? is it possible in SQL? My reader got confused because he only knows about INNER join and OUTER join which require a key column like dept_id which is the primary key in one table like Department and foreign key in another table like Employee. He couldn't answer the question, though he did tell them about you can select data from multiple tables by typing multiple table names in from clause using a comma. What he was saying was right, but he didn't know much about it, so he couldn't explain it confidently. Lucky for him, he got the job but he emailed me asking the same question which inspired me to write this post.

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.

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.

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. They are known as OCAJP and OCPJP in the Java world.

How to Format Date to String in Java 8 and Before - Example Tutorial

One of the common programming task in Java is to change the date format of a given Date or String. For example, you have something like "2017-01-18 20:10:00" and you want to convert it that date into "2017-01-18", or you want to convert from dd-MM-YY to MM-dd-YY or to any other format of your choice and need, but a valid date format as per Java specification. How will you do that? Well, it's not that difficult. It's just a two-step process. In the first step, you need to parse String to create an equivalent date using current format and then once you got the date, you need to again convert it back to String using the new format. The same process is repeated in both Java 8 and before, only corresponding API and classes changes.

Java 8 ConcurrentHashMap 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.

Difference between ISNULL() and COALESCE() function in SQL

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

Can you make an Abstract Class/Method Final in Java?

No, you cannot make an abstract class or method final in Java because the abstract and final are the mutual exclusive concept. An abstract class is incomplete and can only be instantiated by extending a concrete class and implementing all abstract methods, while a final class is considered as complete and cannot be extended further. This means when you make an abstract class final, it cannot be extended hence it cannot be used and that's why Java compiler throws a compile-time error when you try to make an abstract class final in Java. In short, an abstract class cannot be final in Java, using both abstract and final modifier with a class is illegal in Java.

Java - Convert String to Short Example

In last a couple of examples, I have taught you how to convert String to Integer, Long, Double, Float, Boolean, and Byte in Java and today I will show you how to convert String to Short in Java, but before that let's revise what is short data type in Java. The short is an integral data type similar to the int but it only takes 2 bytes to store data as compared to 4 bytes required by an int variable. Since it takes only 2 bytes or 16 bits to store data, the range of short is also shorter than int. It ranges from -32,768 to 32767 (inclusive) or -2^15 to 2^15 -1. You might be wondering why upper bound is 255 and lower bound is -256 but that's because we have included zero in between.

Linux Crontab Command Example - How to backup and load Cron Jobs from a File in UNIX

If you have been using Linux for some time then you might know about cron jobs. They are the scheduler which can be used to automatically start processes in a Linux box. I have worked on many projects which used cron jobs to start the Java process and environment daily or weekly basis. They are similar to Autosys when it comes to scheduling job but cron is a Linux command as opposed to Autosys which is separate application altogether. In Linux, crontab command is used for scheduling and automating jobs or process. You can also use it for loading cron jobs from a file, listing existing cron entries, and editing them. It manages the cron table that is used by the cron daemon in Linux to execute the cron jobs.

Top 20 Hibernate Interview Questions for Java J2EE Programmers

Hibernate is one of the most popular persistent frameworks in the Java world. Hibernate offers an 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.

When and How to use the wait() and notify(), nofityAll() methods in Java? - Example Tutorial

When should you use the wait() and notify method in Java is one of the many popular questions about the wait and notify methods from Java multithreading interview questions. One of the reasons for its popularity is that still a lot of Java programmer struggle to explain and write code using wait-notify methods.  Many Java developer only knows some facts about the wait and notify methods like that wait() and notify() are defined in the java.lang.Object class or you cannot call wait() without synchronization, means without a synchronized block or synchronized method but doesn't really know when and how to use them.