Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
How to use Map.compute(), computeIfPresent() and ComputeIfAbsent in Java? HashMap and ConcurrentHashMap Example
How to use LinkedList in Java? Singly LinkedList and Doubly LinkedList Example Tutorial
Hello friends, we meet again on our journey to Java. I hope you guys are enjoying Java and are trying hands-on too. Today we are gonna discuss a very easy topic (yeah, I mean it :p). But, do not get carried away just by "easy", this is the hottest topic asked in various interviews, exams, and development purposes too. So, what's the wait? Let's start! As usual, let's start with a scenario. Let's say you want a data structure that stores data in a sequential manner, like an array. But, you don't know the size yet while initializing the data structure. Arrays don't support that, they need a size beforehand. So, what should we do? Do not worry, as Java is here to help us again. Let's explore it then!
How to get First and Last Element of LinkedList in Java [Example]
Difference between Thread.yield and Thread.sleep in Java? Answer
[Solved] java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener in Java and Spring
Context.ContextLoaderListener in your Spring-based Java Web application.
Cause: This error comes when you are using the Spring MVC framework in your Java Web application and configured org.springframework.web.context.ContextLoaderListener as a listener in your deployment descriptor also known as web.xml, but the JAR which contains this class is not available in the web application's CLASSPATH.
How to fix org.springframework.beans.factory.BeanCreationException: Error creating bean with name X [Java Spring]
BeanInstantiationException: Could not instantiate bean class [X]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.()
Here X is the class, which is declared as Spring bean. The error clearly says that the default constructor is not present in class X.
Difference between Serializable vs Externalizable in Java - Interview Question
What is the use of DispatcherServlet in Spring MVC? Interview Question Example
What is @Bean Annotation in Spring Framework? Example Tutorial
How to delete multiple elements from a LinkedList in Java? SubList() Example
What is TreeMap in Java? HashMap vs TreeMap Example Tutorial
How ThreadLocal variables works in Java? Explained
Difference between JIT and JVM in Java? Answered
Visitor Design Patterns In Java Examples Tutorial
Hello guys, if you want to learn Visitor design pattern in Java then you have come to the right place. Earlier, I have covered many design patterns like Decorator, Strategy, State, Composite, Adapter, Command, Template, Factory, Observer and even few Microservice patterns like SAGA and Database per service and in this article, I will talk about Visitor Design Pattern and how to implement in Java. You will learn things like what is Visitor design pattern, what problem it solves, what are pros and cons of Visitor design pattern, when to use Visitor pattern as well as any alternatives of Visitor Pattern in Java. I will also show you a real world example of Visitor design pattern, but, before we get to the 5 best examples that will teach you all about design patterns in Java, let me tell you a little bit more about what it really is.
Difference between 32-bit vs 64-bit JVM in Java?
10 Examples Of Mockito + JUnit in Java for Unit Testing
How to convert Java 8 Stream to Array and ArrayList in Java? Example Tutorial
Array length vs ArrayList Size in Java [Example]
How to create an ArrayList from Array in Java? Arrays.asList() Example Tutorial
One of the common problems faced by junior and less experienced Java developers is converting an array to ArrayList e.g. they are getting an array from somewhere in their code and then want to create an ArrayList out of that so that they can add more elements and use other library methods which operate with ArrayList or List. The simplest way to convert an array to ArrayList is by using the Arrays.asList() method, which acts as a bridge between Collection classes and array data structure. This method returns a List that contains elements from an array.