Difference between HashMap and ConcurrentHashMap in Java? Example

HashMap vs ConcurrentHashMap in Java
What is the difference between an HashMap and ConcurrentHashMap in Java is one of the common interview questions and knowing the answer is not just important for interviews but also for writing robust and high performance Java cocd. ConcurrentHashMap in Java is introduced as an alternative of Hashtable in Java, which is a synchronized collection class, that makes the main difference between HashMap and ConcurrentHashMap which is one is non-synchronized , non-thread safe and not for use in Concurrent multi-threaded environment while ConcurrentHashMap is a thread-safe collection and intended to be used as primary Map implementation especially for multi-threaded and Concurrent environment. 

How to iterate over an Array in Java using foreach loop Example Tutorial

Though there are many ways to loop over Array in Java, including classical for loop, while loop with length counter, nothing matches the elegance of Java 1.5 foreach loop, which makes iteration super easy and super cool. When we need to iterate through each element of an array and have to perform some operation on them e.g. filtering, transformation, or simply printing, the foreach loop comes to its full glory. There is not much difference between traditional for loop and Java 1.5 foreach loop, except that the former has counter and condition, which is checked after each iteration.

Difference between List and Set in Java [Answered]

List vs Set in Java
The main difference between List and Set is that List is an ordered Collection while Set is an unordered collection. Java collection framework offers several collection classes for various needs but all collections can be divided into broadly three categories: List, Set, and Map. All List, Set, and Map are defined as interfaces and then you have several implementations like ArrayList and Vector are the popular implementation of List interface, while HashSet is a popular implementation of the Set interface. 

Top 5 Books to learn Core Java for Beginners in 2023 - Best of lot

I receive half a dozen emails every day asking about which is the best to learn Java from scratch? Which book should I read in 2023 to learn Java? Or Which is the best Java for beginners? When I receive such an email, before giving my recommendation, I ask two questions, first do you have any programming experience? like, Are you coming from C, C++, or Python background? Or you are a fresher with no experience in programming, just a couple of classes on data structure and algorithm and operating systems in college.

Top 5 Free Object-Oriented Programming Courses for Java Programmers in 2023 [UPDATED]

The OOP or Object Oriented Programming paradigm allows you to write a program by modeling real-world things in terms of class and object. It makes representing a real-world thing in the programming world smoother and will enable you to manage the complexity of your program. Even though several programming paradigms, like procedural and functional, most of the code we write today is object-oriented. Some of the most popular programming languages are object-oriented, like Java, Python, PHP, and JavaScript, all supported object-oriented programming.

2 Ways to Remove Elements/Objects From ArrayList in Java [Example]

There are two ways to remove objects from ArrayList in Java, first, by using the remove() method, and second by using Iterator. ArrayList provides overloaded remove() method, one accepts the index of the object to be removed i.e. remove(int index), and the other accept objects to be removed, i.e. remove(Object obj). The rule of thumb is, If you know the index of the object, then use the first method which accept index, otherwise use the second method. By the way, you must remember to use ArrayList remove methods, only when you are not iterating over ArrayList if you are iterating then use Iterator.remove() method, failing to do so may result in ConcurrentModificationException in Java. 

Top 5 Online Courses to Learn Power BI in 2023 - Best of Lot

If you want to become a Data Analyst or Data Scientist or you are doing Data Analytics and Data visualization and want to learn Microsoft Power BI then you have come to the right place. In the past, I have shared the best courses to learn Tableau, QlikView, D3.js, and Excel, and today and I going to share the best online courses to learn Microsoft Power BI, another top-class Data Visualization tool. If you have been interested in Data Visualization and Analysis then you might have come across Microsoft Power BI, a cloud-based powerful data visualization tool that is quickly getting very popular among Business Analysts and other technical people who work with Data.

Top 7 Online Courses to Learn Spring Framework in 2023 - Best of Lot

Hello Java developers, if you want to learn Spring Framework and look for the best resources like books, online courses, and tutorials, you have come to the right place. Earlier, I have shared the free Spring Framework courses, best spring framework books, and best Spring Boot courses, and today, I Am going to share the best Spring Framework courses for Java developers. It is one of the world's most popular development frameworks for using enterprise Java. It is used by millions of developers for creating easily testable, reusable, and high-performance code, and it is also one of the essential skills for Java developers. If you are not familiar with the Spring framework, this should be the first thing you should learn in 2023. 

Top 6 Free Courses to Learn Web Development in 2023 - Best of Lot

Hello guys, I have been sharing a lot of free online courses and books on various technology and programming language like Python, Java, C++, JavaScript, PHPReact, Angular, Spring in this blog for quite some time, and today I have brought some great free courses to learn the basics of web development. Web Development is an essential skill for programmers in this era of Startups. As a programmer or software developer, you should know how to create a website and create a mobile app of your own. Though it's not easy. Coding is like art, and many people are born with a coding sense; I mean, they love coding; they love to create stuff like websites, mobile apps, games, etc., and they love to automate things.

Top 10 Free Courses to become Fullstack Java Developer in 2023 - Best of Lot

Hello guys, if you want to become a full-stack Java developer and are looking for free online Java Full-stack development courses to kickstart your career, you have come to the right place. Earlier, I have shared the best Java full-stack development courses, and today, I will share 10 of the free online courses you can join to become a full-stack Java developer. The long journey of becoming a full-stack Java developer is not easy. You need to know all the details, from the front end to the backend. Not only these, but you also need to know how things function in databases and connectivity.

Top 6 Free Maven and Jenkins Online Courses for Java Programmers in 2023 [ UPDATED]

Hello Java programmers,  if you want to learn Maven and Jenkins and look for free resources like free online courses, you have come to the right place. Earlier, I have shared the best Maven courses and best Jenkins courses, and in this article, I will share the best free Jenkins and Maven courses for Java programmers. If you have been doing professional Java development, you know that Maven and Jenkins are two of the most popular tools in the Java world. Maven helps organize your project and provide support to build and deploy Java projects, while Jenkins can provide continuous integration and delivery by completely automating build and deploy projects.

Top 5 Free Bash and Shell Scripting in Linux for Beginners in 2023 - Best of Lot

Hello guys, the importance of Linux is well known but many programmers don't know how to write shell scripts to make most of it.  Some of them even not familiar with various Linux shells like bash, csh, or ksh, which further limits their ability. If you don't know, bash is a UNIX shell and command language, which is also a default login shell for many Linux systems and Mac OS. It provides the ability to write scripts to do things programmatically.  Shell scripting is an important skill to become an efficient developer or programmer. It allows you to automate trivial tasks that otherwise take away your valuable time. It also allows you to do things quickly.

Top 5 Free Online Courses to Learn Eclipse and JUnit for Beginners in 2023 - Best of Lot

Both 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 programs from a single window. At the same time, JUnit is a unit testing library that will automatically test your Java code. 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.

Top 5 Free Android Development Courses for Beginners in 2023 - Best of Lot

Hello guys, If you are passionate about creating mobile games and applications and want to learn how to develop Android apps or become an Android application developer, you have come to the right place. In the past, I have shared the free Android books and best Android training courses, and In this course, I will share some of the best and free Android development courses for Java programmers and others. You might know that earlier, Java was the only language that was used to create Android applications. Still, since last year, Google has announced Kotlin as the official language for Android app development, which means you can use either Kotlin or Java to create Android apps.

5 Free Oracle and Microsoft SQL Server Online Courses [2023] - Best of lot

If you are an application developer, like 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 5 Free Servlet, JSP, Java FX, and JDBC Courses for Java Web Developers in 2023 - Best of Lot

If you are a Java developer working on a Java JEE projects like a Java Web application running on Tomcat or Glassfish, 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 essential 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 the real world.

Top 10 Websites to Learn JavaScript Coding for FREE in 2023 - Best of Lot

Hello guys, if you want to learn JavaScript and are looking for the best websites to learn JavaScript programming for FREE, you have come to the right place. Earlier, I shared the best free JavaScript courses and paid JavaScript courses, and in this article, I will list down the best websites to learn JavaScript for FREE. We live in a world of the internet, which is full of resources. You can know whatever you want and that too, without spending too much money. If you're going to learn JavaScript, there are plenty of websites where you can learn JavaScript online for FREE

Top 5 Courses to Learn Linux and UNIX in 2023 - Best of Lot [UPDATED]

Hello guys, if you want to learn Linux operating systems and command lines and look for the best Linux courses, you have chosen the right place. In the past, I have shared some free Linux courses and bash scripting courses for programmers and developers, and many of you asked for more comprehensive online Linux courses to learn Linux in-depth, which motivates me to write this article. In this article, you will find the best Linux online training classes, online paths, and tutorials from Udemy, Pluralsight, Coursera, and edX, my favorite online learning platforms.  

Top 6 Dynamic Programming Online Courses for Coding Interviews in 2023 - Best of Lot

Hello guys, if you are preparing for a coding interview but struggling to solve Dynamic programing based coding problems and looking for the best resource to improve your Dynamic programming skill then you have come to the right place. Earlier, I have shared the best coding interview courses and best Recursion courses,  as well as popular  Dynamic programming problems from interviews, and today I am going to share the best online courses to learn Dynamic programming in depth.  Dynamic programming simply means that plain recursion can be optimized when there are repeated calls for some inputs.

5 Free Blockchain Developer Courses and Certifications to Learn in 2023 - Best of Lot

Hello guys, if you want to learn Blockchain development and are looking for some free Blockchain courses, you have come to the right place. Earlier, I shared my favorite and best blockchain courses for programmers, and a lot of you asked for free online courses to learn Blockchain, so today, I am going to share the best free Blockchain development courses you can join in 2023. Blockchain is one of the most in-demand technologies and one skill that you should learn in 2023. It will not only help in your career but also raise your profile. This is one thing I have highly recommended programmers to learn this year. 

Top 5 Free Courses to Learn React in 2023 - Best of Lot

React.js, React JS, or React is one of the most popular frameworks or JavaScript libraries for building user interfaces. It's backed by Facebook, and it's often viewed as an alternative to the tremendous 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 the React framework. It is developed at Facebook and it focuses on the 'View' aspect of MVC in web applications. The component-based development is one of the biggest advantages of the React library which is both rich and extensible.

3 Best Books to Learn Java Programming for Beginners

Hello guys, if you want to learn Java from scratch and looking for the best Java books then you have come to the right place. Earlier, I have shared the free Java courses for beginners, and today, I am going to share the best books to learn Java from scratch. There is no doubt that the best book to learn Java for beginners is indeed Head First Java, 3rd Edition. It's interesting, informative, and yet easy to read, which is what a beginner wants. The only drawback of this book was that there is was 3rd Edition available until a couple of months ago but now that drawback has also gone as the 3rd Edition of Head First Java is now available and it covers Java SE 17, the latest version of Java. 

5 Free Linux Courses for Programmers and IT Professionals to Learn Online [2023]

Linux is one of the most popular operating systems to run server-side applications. I have seen almost all Java applications running on Linux, barring a couple of them, which run on Windows as a service. If you take out standalone apps like IDEs or tools, most of the real-world Java applications run on Linux, like payment gateways, trading systems, and other financial applications. That's why it's essential for any programmer, IT professional, or developer to learn and understand Linux, both the operating system, as well as the command line.

How to swap two Integers without using a temporary variable in Java?

One of the oldest trick questions from a programming interview is, How do you swap two integers without using a temp variable? This was first asked to me on a C/C++ interview and then several times on various Java interviews. The beauty of this question lies both in the trick to thinking about how you can swap two numbers without the third variable, but also problems associated with each approach. If a programmer can think about integer overflow and consider that in its solution then it creates a very good impression in the eye of interviewers.

How to check if File is Empty in Java? Example Tutorial

One of the readers of my blog Javarevisited emailed me yesterday about how to check if a file is empty in Java and that's why I am writing this post to show that using an example. The common approach for checking if a file is empty or not is to first check if the file exists or not and then check if it contains any content, but Java has done that hard work for you. Well, it's pretty easy to check emptiness for a file in Java by using the length() method of the java.io.File class. This method returns zero if the file is empty, but the good thing is it also returns zero if the file doesn't exist. This means you don't need to check if the file exists or not.

10 Free Courses to Learn Data Structure and Algorithms in Java, Python, and C++ [UPDATED]

Algorithms and Data Structure are two of the most fundamental and essential topics in Computer Science, which is used everywhere in software development. I firmly believe that a good knowledge of these two topics is also crucial to becoming a better programmer because a person who has a good understanding of algorithms and data structures can make thoughtful choices and write programs that can handle changes better and perform well. They are also essential to crack coding interviews at top tech companies like Google, Microsoft, Amazon, Facebook, and Apple, which emphasizes candidates' ability to use existing data structures and algorithms to solve complex problems they have never seen before.

Top 6 Free Docker Courses for Beginners in 2023 - Best of Lot

If you are an application developer working in Java, Python, JavaScript, C#, or any other language and want to become a DevOps engineer or someone who wants to learn Docker, then you have come to the right place. In this article, I will share some of the best free Docker courses you can use to 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 a Docker is and how it works, let me briefly introduce it.

[Solved] How to Print Alphabets in Upper and Lower Case in Java? Example Tutorial

Hello guys, if you are learning Java and looking for basic programming exercise to build your concepts then you have come to the right place. Earlier, I have shared 15 common Java programming exercises and today, you will learn one of them. One of the textbook exercises to get started with any programming language is writing a program to print alphabets in both upper and lower case. This program allows you to explore the String class in Java with the toUpperCase() and toLowerCase() method but normally when you start, it's asked to do this without any API methods.

Top 21 Websites to Learn Programming for FREE in 2023 - Best of Lot

Hello folks, if you want to learn Coding from scratch and looking for some free online training websites or are someone who is learning programming and Coding by yourself and looking for some fantastic free websites and coding platforms, then you have come to the right place. Earlier, I shared free courses to learn Java, Python, and JavaScript, and In this article, I will share 21 websites to learn Coding for FREE. These are absolutely free online training websites and platforms you can use to learn programming languages and essential software skills like web development,  machine learning, automation, and app development for free from the comfort of your office and home.

[Solved] How to count Vowels and Consonants in Java String Word? Example

Hello guys, if you are wondering how to count number of vowels and consonants in a given word in Java then you have come to the right place. In the past, I have shared 100+ data structure questions and more than 75 programming interview questions, and In this article, we will take on a popular programming exercise of counting vowels in a word. You need to write a Java program to count how many vowels in a String, which is entered from the command prompt. It's similar to the program of counting the occurrence of characters in a String, in fact, it's a special case, where you need to count occurrences of all vowels, which includes five characters a, e, i, o and u

[Solved] How to convert Hexadecimal to Decimal, Binary and Octal in Java? Example

Hexadecimal to decimal and binary conversion in Java
Hello guys, if you are wondering how to convert a Hexadecimal number to decimal and binary number in Java then you have come to the right place. Earlier, I have shown you how to convert decimal to binary in Java and in this Java program will convert Hexadecimal number to decimal, binary and Octal in Java programming language using JDK standard API methods. For beginners who are not familiar with number system, hexadecimal system is base 16 number, while decimal is base 10, Octal is base 8, and binary is base 2 numbers in Number systems. 

How to create a Function to add two numbers in Java? Variable Argument Example Tutorial

How to add two numbers in Java
Hello guys, if you are just starting with Java programming and wondering how to write a function to add two numbers in Java then you have come to the right place. In this Java program tutorial, we will add two numbers provided by the user on the command line. Write a Java program to add two numbers in Java is a common programming exercise for programmers and mostly asked in college exams, school homework, and Java courses as well. 

5 Free Online Courses to Learn Kotlin in 2023 - Best of Lot

Hello guys, If you are in Android application development or server-side Java development, then you might have heard about the Kotlin programming language, created by JetBrains, the company behind popular IDEs like IntelliJIDEA, PyCharm, and WebStorm. Kotlin is also Google's official language for developing Android apps. If you don't know what Kotlin is and why you should learn Kotlin, then let me tell you that Kotlin is a mature programming language that offers many benefits over traditional programming languages like Java which has been time-tested over the last 25 years. Kotlin is designed to solve pain points of Java programming language like verbose nature and boilerplate.

How to Convert Stream to ArrayList in Java 8 - Collectors.toCollection() Example

You can use Collectors.toList(), toSet(), and toMap() to get all elements of Stream into any Collection like List, Set or Map, but if you want to get a particular collection e.g. ArrayList, then you need to use Collectors.toCollection(ArrayList::new) method. This method first creates an ArrayList using method reference and then adds all elements of Stream into the ArrayList. It's very useful if you have a long list of String and you want to create a smaller list containing only String starting with the letter "b"  like "Bluehost"

3 Examples to Loop over a List in Java - ArrayList, LinkedList or Vector

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 a List and because of this, you can also use a traditional for loop which keeps count for iterating a 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. 

RegularEnumSet vs JumboEnumSet in Java

Hello guys, the difference between RegularEnumSet and JumboEnumSet in Java was asked in a recent Java interview with one of my friends, unfortunately, he hasn't explored this topic well and couldn't answer this question precisely, but he made sure to learn about EnumSet after that. When he discussed this topic with me, I really liked it because, despite the usefulness of EnumSet and its fast implementation, not many developers know about it, despite being mentioned in Java's classic Effective Java. This makes me write this post, where we will mainly discuss a couple of differences between RegularEnumSet and JumboEnumSet in Java, but we will also touch base upon some of the important properties of EnumSet.

Top 5 Courses to Learn Agile and Scrum Methods in 2023 - Best of Lot

If you are a programmer, software developer, team lead, or project manager who wants to learn Agile and Scrum in 2023 and looking for the best Agile courses, then you have come to the right place. Earlier, I shared free Agile courses and books, and today, I will share the best Agile and Scrum online courses you can join in 2023 to learn these in-demand skills. The Agile software development approach is a powerful approach that is very popular among the development community. As technology advances rapidly, the client expectations are high, and the delivery time is less.

Top 5 Courses To Learn Data Analytics in 2023 - Best of Lot

Hello guys, if you want to learn Data Analytics and looking for best online courses and tutorials then you have come to the right place. In the past I have shared best Data Science Courses and things a Data Scientist should learn and in this article, I am going to share best online courses to learn Data Analytics. The list includes best Data Analytics courses from Udemy, Coursera, Pluralsight, and other popular online learning platform. They are taught by experts and they are also the most comprehensive and up-to-date resources to learn Data Analytics in 2023. 

Top 6 Courses to Learn Google Cloud Platform or GCP in 2023 - Best of Lot

Hello folks, if you want to learn Google Cloud Platform in 2023 and looking for the best resources like online courses, books, websites, and tutorials then you have come to the right place. Earlier, I have shared the best free Google Cloud platform courses and best websites to learn GCP, in this article, I am going to share the best online courses to learn Google Cloud Platform in 2023. The Google Cloud Platform, or GCP, is similar to Amazon Web Services and is a public cloud vendor catering to businesses and enterprises. Customers can use the Google Cloud Platform to access the computer resources in Google's data centers present across the world. It is offered either as a free addition or on a pay-per-use basis.

Top 6 Free Courses to Learn Bootstrap Online for Beginners in 2023 [UPDATED] - Best of Lot

Bootstrap is one of the most popular front-end libraries, which provides a customizable HTML, CSS, and JavaScript template for creating a modern and responsive website. All the beautiful websites you see these days with large fonts and slick form fields are built using Bootstrap. If you want to learn Bootstrap and looking for some excellent online courses, then you have come to the right place. In the past, I have shared advanced CSS courses to learn Flexbox, Grid, and SaaS, and in this article, I will share some of the excellent Bootstrap courses, which are also free, and you can use them to kick-start your journey with the Bootstrap framework. If you are interested in modern web development, this is the framework you must learn this year.

How to convert an Array to Collection like Set and List in Java? Example Tutorial

Hello Java programmer, if you are wondering how to convert an Array to Collection like Set or List in Java then you have come to the right place. In the past, I have shared how to convert ArrayList to HashMap in Java and In this example, we will learn how to convert a String array to Collection, Set or List in Java. You can convert an Array to Collection using helper method Arrays.asList() in Java. This is shortcut to convert array to List , Set or any Collection. This knowledge of converting an array to Collection can be really useful to any Java developer, as most legacy code tend to use an array, which means you either need to pass them your input as array or they return the result as an array. 

[Solved] How to solve climbing stairs problem in Java? Example

In this article, we are going to be solving the stairs problem using java, After that, I shall be explaining the concept of Array. but before we start writing codes it is fine to have an understanding of the problem we are about to solve. Given the number of stairs and the number of times you can move your legs, we would see how many possible ways you can achieve the climbing of stairs. The image below shows different possible ways you can climb stairs. For instance, let us say we have 5 steps on the stairs. and you can either walk with 2 moves or 1. 

How to Iterate over HashMap in Java? Map.entrySet().iterator() Example

What is the best way to Iterate over HashMap in Java? and not just HashMap, but any Map implementation including old Hashtable, TreeMap, LinkedHashMap and relatively newer ConcurrentHashMap, is a frequently asked query from Java Programmers, with some experience under his belt. Well, when it comes to choosing between different ways to iterate over Map in Java, it's you need, which plays an important role. For example, if you just want to iterate over each entry of HashMap, without modifying Map, then iterating over entry set using Java 1.5 foreach loop seems the most elegant solution to me.