Wednesday, June 29, 2022

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. 

Monday, June 27, 2022

Top 5 Books to learn Core Java for Beginners in 2024 - 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 2024 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 2024 [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.

Sunday, June 26, 2022

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 7 Online Courses to Learn Spring Framework in 2024 - 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 2024. 

Friday, June 24, 2022

Top 6 Free Courses to Learn Web Development in 2024 - 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 2024 - 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.

Wednesday, June 22, 2022

Top 5 Free Bash and Shell Scripting in Linux for Beginners in 20243 - 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 2024 - 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.

Monday, June 20, 2022

Top 5 Free Android Development Courses for Beginners in 2024 - 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 [2024] - 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.

Sunday, June 19, 2022

Top 5 Free Servlet, JSP, Java FX, and JDBC Courses for Java Web Developers in 2024 - 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.

Friday, June 17, 2022

Top 6 Dynamic Programming Online Courses for Coding Interviews in 2024 - 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.

Friday, June 10, 2022

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

Thursday, June 9, 2022

Top 6 Free Docker Courses for Beginners in 2024 - 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.

Wednesday, June 8, 2022

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

Tuesday, June 7, 2022

Top 21 Websites to Learn Programming for FREE in 2024 - 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. 

Monday, June 6, 2022

5 Free Online Courses to Learn Kotlin in 2024 - 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"

Sunday, June 5, 2022

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 2024 - Best of Lot

If you are a programmer, software developer, team lead, or project manager who wants to learn Agile and Scrum in 2024 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 2024 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.

Thursday, June 2, 2022

Top 5 Courses To Learn Data Analytics in 2024 - 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 2024. 

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

Hello folks, if you want to learn Google Cloud Platform in 2024 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 2024. 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 2024 - 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.

Wednesday, June 1, 2022

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.