Wednesday, April 26, 2023

React Native vs Flutter? Which is better to learn for App Development in 2024?

Hello guys, if you are wondering whether to learn Flutter or React Native for App Development in 2024 then you have come to the right place. Earlier, I have shred best courses to learn Flutter and React Native and in this article, I will share my thoughts on which one is better suited for App development in 2024 and which mobile app development framework beginner should learn in 2024. In the recent decade, the mobile application community has grown tremendously. The total number of applications on the play store surpassed one million in the year 2013 and by mid-2020, it was estimated that there are more than 2.8 million applications on the google play store. 

Angular vs React vs Vue.js ? Which is better to learn web development in 2024?

JavaScript web frameworks are important parts of modern web development. Several JavaScript web framework and libraries are active today. If you plan to become a web developer, you may encounter these web frameworks. A web developer, especially a front-end web developer should be skilled in at least one of these frameworks. Angular and React are the two most popular web frameworks and libraries today. Vue.js is the rising star. In this article, we will compare these three frameworks on different parameters like Community support, Performance, ease of Learning, and jobs to find out which frontend development framework between Angular, React.js and Vue.js you should learn in 2024. 

How to Find Lowest Common Ancestor of a Binary Tree in Java? Example Tutorial

Hello guys, if you are wondering how to find the lowest common ancestor of a binary tree in Java then you are at the right place. Earlier, I have shared 40+ binary tree questions and today I am going to share solution of one of the popular binary tree question here. To find the lowest common ancestor of a binary tree in java requires that we run through a binary search tree and how it operates.  What then is a binary search tree? A Binary tree is a data structure in which each node can have at most two children. That is, each node in the binary tree will have data, left child and right child. The first node of the tree is called the Root.

8 Examples of Primitive Data Types In Java (int, long, boolean, float, double, byte, char, and short)

Hello guys, Data types are first few things you should learn when you start learning a programming language and when it comes to learn Java, there are 8 primitive data types which you should know. These are divided into three categories, numeric, text, and boolean values. Numeric data types can be further divided into two like natural numbers and floating pointing numbers. But, Before we get to a list of the 10 examples of primitive data types in Java, let me tell you a little bit more about what the primitive data types are.  There are essentially 8 primitive data types in Java. They are int, byte, short, long, float, double, boolean, and char. The primitive data types are not considered objects and represent raw values. These primitive data types are also stored directly on the stack.

10 points on TCP/IP Protocol, Java Programmers should Know

TCP/IP is one of the most important protocol as its backbone of HTTP, internet and most of the communication happens today. It's also important from technical interview perspective, you might have already seen difference between TCP and UDP multiple time during interviews ( I have seen). I believe every programmer, not just Java developer should know what is TCP/IP protocol? How it works and the below points I am going to mention. These are basic points and most of you already know but during Interview I have found many developers who doesn't really know what TCP/IP offers and how it works and what are the pros and cons of TCP/IP protocol. That's where, I think this article will help you. Anyway, let's jump into technical details now. 

Monday, April 24, 2023

What is try with resource in Java? Example tutorial

In Java we normally use resources like file, network connection, socket connection, database connection etc ,dealing with resources is not a difficult task but what if after using the resources programmers forget to close the resources. As we know in Java everything is Object so if we forget to close or shut down the resource its responsibility of GC that will recollect it when its no longer used but we can reduce resource exhaustion by explicitly closing the resources as soon we done with our job with the resources. Some resources like database connection are very precious and would surely run out of resources if waited for finalization. Many database servers only accept a certain number of connections so if forget to close properly will create problem.

How to get the first and last item in an array in Java? Example Tutorial

Firstly, before going about finding the first and the last item of an array in java. We need to fully understand what an array is and how it works. What then is an Array? An array is a data structure in java that holds values of the same type with its length specified right from creation time. Think of a container, like a crate of eggs or coke. What I am trying to say is that when you are creating your array, the items coming in must be the same as you have specified as length and you must specify how many items are coming. If you have stated that the items coming are integers, so it is and no other data type (e.g string, char e.t.c) can be there and vice versa. Or you can say an array is a collection of similar type of elements which has contiguous memory location.

Difference between array and Hashtable or HashMap in Java

A couple of days back someone asked me about the difference between an array and a hashtable, though this is a generic data structure and programming question, I'll answer it from both a general programming perspective as well on Java perspective where Hashtable is not just a data structure but also a class from Java Collection API. Even though both array and hashtable data structure are intended for fast search i.e. constant time search operation also known as O(1) search, the fundamental difference between them is that array require an index while hash table requires a key which could be another object. 

How to replace Anonymous Class to Lambda Expression in Java 8? Example Tutorial

Hello guys, you may be thinking why I am talking about Anonymous class now when many Java programmers have already switched to Java 8 and many have already moved on from Anonymous class to Lambda expression in? Well, I am doing it because I am seeing many Java programmers who find it difficult to write and read code using lambda expression in new Java 8 way. It's also my own experience that if you know the problem first, you can better understand the solution (lambda expression). Some of you might remember, the opening scene of MI 2 (Mission Impossible 2), when Nekhorovich says to Dimitri that "Every search for a hero must begin with something that every hero requires, a villain. Therefore, in our search for a hero, Belairiform, we created the monster, Chimera"

Java FileReader + BufferedReader Example

There are multiple ways to read a file in Java e.g. you can use a Scanner as we have seen in the last example, or you can use the BufferedReader class. The advantage of using a BufferedReader to read a text file is speed. It allows faster reading because of internal buffering provided by BufferedReader. Other Reader classes like FileReader access the file or disk every time you call the read() method but BufferedReader keeps 8KB worth of data in its internal buffer which you can read it without accessing the file multiple times. It's loaded when you access the file the first time for a subsequent read.

10 Examples of print(), println() and prinf() methods In Java - PrintStream

Hello guys, if you are working in Java or just started with Java then you have must come across statements like System.out.println("Hello world") to print something on console or command prompt. This is actually the first statement I wrote in Java when I started programming and at that time I didn't realize how it work and what is System and PrintStream class and what is out here but now I know and I am going to explain all this to you in this article, along with PrintStream class and its various print methods like print(), println() and particularly printf() to print various objects in Java. But,   Before we get to the 10 examples of Printstream printf() in Java, let me tell you a little bit more about what exactly Printstream is. 

Chain of Responsibility Pattern in Java? Example Tutorial

Hello guys, if you have been doing Java development then you must have come across design pattern, tried and tested solution of common software problem. In the past, we have looked at several popular Object Oriented Design Patterns in Java like Adapter, Decorator, State, Strategy, Template, Composite, Command, Observer, Factory, Builder, Visitor etc, and today I am going to talk about Chain of Responsibility design pattern in Java. The Chained or Chain of Responsibility Pattern is a design pattern that allows a request to be passed along a chain of objects until it is handled by one of the objects in the chain. This pattern is helpful for situations where it is not known in advance which object in the chain should handle the request, or where the request needs to be handled by multiple objects in the chain.

Sunday, April 23, 2023

Top 10 Projects to Learn Front-End Web Development

Hello guys, If you are looking for ways to learn Front-End Web Development, you have come to the right place because all of what you want is right here. You just have to keenly go through this article till the end and you will get what you need.  Front-end web development is a popular field that involves creating the user interface and experience of websites and web applications. It is an ever-evolving field that requires developers to stay up-to-date with the latest tools, technologies, and trends. One of the best ways to learn front-end web development is through hands-on projects. In this article, we will explore the top 10 projects that can help you learn front-end web development and enhance your skills in HTML, CSS, JavaScript, and other related technologies. 

How to use @JsonCreator and @JsonPropertOrder Jackson JN Annotation in Java? Examples

Hello guys, if you are dealing with JSON in Java then you may have come across Jackson, one of the popular JSON library in Java. Jackson provides many cool annotations to serialize and de-serialize JSON to Java object and vice-versa. Earlier, I have showed you 3 ways to convert JSON to Java object and 10 free Jon Tools for programmers and in this article, we will deep dive into two popular Jackson annotations @JsonCreator, @JsonProperty, and @JsonProperOrder. But, Before I tach you exactly how you can use the @JsonCreator annotation, let me briefly tell you a bit more about what Java really is.

Top 5 Functional Interface Every Java Developer Should Learn

Hello guys, functional interface in Java are an important concept but not many developer pay enough attention to them. They learn lambda and method reference but the functional interface from java.util.function package. While its not really possible to learn all the functional interfaces on that package but you can learn a few more commonly used ones like Predicate, Supplier, Consumer etc and that's what you will learn in this article.  But, before we get to the top 5 functional interfaces that every Java developer should learn, let me tell you a bit about what Java really is. 

Difference between Class and Object in Java? Example

Class and Object are two pillars of Java and any Object oriented programming language. There are multiple ways you can describe Class in Java, I will start with how I remember class from my college Days. That time, I used to remember that "A class is a blueprint to create object" and that's how I answer during viva or exam. While I know what is a blueprint, I didn't really understand what a class can do. Later, when I started coding, I learned about data types like int data type to hold integer values. String data type to hold text values.  

How to convert List Of of Object to Map of Object (key, value) In Java? Example Tutorial

Hello guys, if you have a list of object and you want to conver into Map of object or key value pair then you can use different ways like looping over list and then adding values to map, or you can use Collectors.toMap() by using Stream API, You can even use flatMap() function if you want to convert list of one type of object to Map of another type of object. All this is possible and I will show you code example of how to do that in this article, But, before we get into the process of how you can convert a list of one object to another in Java, let me tell you a bit more about what Java really is. 

What is WeakHashMap in Java? HashMap vs WeakHashMap Example Tutorial

Hello friends, we are here today again on our journey to Java. I hope everyone is fine and ready to board our train of knowledge. Today we are gonna learn something very interesting and very exciting. Today's topic will definitely be very useful in coding and programming. This topic would surely decrease your time complexity, and space requirements for any task very significantly :p So what's the wait? Let's start!

JDBC - Difference between PreparedStatement and Statement in Java? Answer

If you have worked with database interfacing with Java using JDBC API then you may know that the JDBC API provides three types of Statements for wrapping an SQL query and sending it for execution to the database, they are aptly named as Statement, PreparedStatement, and CallableStatement. First, a Statement is used to execute normal SQL queries like select count(*) from Courses. You can also use it to execute DDL, DML, and DCL SQL statements. 

Can you make a class static in Java? Example

This is one of the tricky questions in Java because there is no straightforward. 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 to 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 a 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.

Difference between Fixed and Cached Thread pool in Java Executor Famework

There are mainly two types of thread pools provided by Javas' Executor framework, one is fixed thread pool, which starts with fixed number of threads and other is cached thread pool which creates more threads if initial number of thread is not able to do the job. The newCachedThreadPool() method is used to create a cached pool, while newFixedThreadPool() is used to construct a thread of fixed size. Cached thread pool executes each task as soon as they are submitted, using an existing thread if its idle or creating new threads otherwise, while in case of fixed thread pool, if more tasks are submitted then idle threads then those task are put into a queue and later executed once any other task has finished.

Difference in Method 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 programming 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 the 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 the same name and signature in parent and child class then the method in the child class will hide the method in the parent class.

Difference Between Iterator and Enumeration In Java

What is the difference between Iterator and Enumeration in Java is one of the oldest core Java Interview Questions. While I haven't seen this question for a long time, I still think its an important concept to know and remember for Java developers, especially those who are tasked to work in existing project which may be using Enumeration. The Iterator and Enumeration are two interfaces in Java and used for traversing in java collection we found these two interface in the java.util package .whenever we go for an interview if interviewer goes in collection topic he will often ask the difference between this two .so let's see one by one difference between this two and compare which is used when and which one is better.

Saturday, April 22, 2023

Top 20 Docker Interview Questions Answers Java Developers and DevOps

Hello guys, if you are preparing for a Java developer interview, a DevOps engineer interview or any software developer interview, one tool which should pay most attention is Docker. It's a container tool which allows you to package and deploy your application in cloud. Docker has many benefits as it not only standardized packaging and deployment but works nicely with Kubernetes which takes the scalability and automatic restart of your application. These are just a couple of benefits but because of all these, Docker has become an essential tool for every programmer and developer and that's why they are also quite important for interviews. 

Top 30 Gradle Interview Questions Answers for Experienced Java Developers

Hello guys, if you are preparing for Java or Kotlin developer interview where Gradle skills are needed then you should prepare for Gradle related questions. I have seen many interviewer asking Maven and Gradle related questions during interviews and many Java developer don't prepare them. But, considering you are looking for Gradle questions I think you are one step ahead of them and If you are looking for Gradle interview questions then you have come to the right place. Earlier, I have shared Maven Interview Questions and in this article, I am going to share Gradle interview questions for Java and Kotlin developers. 

Top 24 Node.js Interview Questions with Answers for 1 to 2 Years Experienced Web Developers

Hello guys, if you are preparing for a JavaScript developer or web developer and looking for common Node.js questions to prepare for interviews then you are at right place. In the past, I have shared JavaScript interview questions, React Questions, Angular Questions and even web development questions and in this article, I am going to share frequently asked Node.js questions with answers for interviews.  Though Node.js is defined as a JavaScript environment, it is widely considered as a backend framework. Since its inception in 2008, Node.js has become a popular term in the server-side development community. More and more companies are using Node.js for backend development.

Difference between Proxy and Decorator Pattern in Java

Hello guys, if you have gone through a couple of Java Developer interview then you may seen this question about Proxy and Decorator Pattern in Java. Earlier, I have share 18 Design Pattern questions and today, I am going to answer this tricky design pattern questions from Java interviews. I was first asked about difference between Proxy and Design Pattern in Java a couple of years back when I was interviewing for Senior Java developer interview on a big investment Bank and I wasn't able to impress interviewer with my answer, so I decided to learn more and this article is the result of that research. Though both Proxy and Decorator pattern looks very similar to each other structurally, there are some key differences between them like what problem them solve and how they are used in Java application. 

[Solved] How to find the Longest common prefix in Array of String in Java? Example Tutorial

Hello guys, If you are preparing for technical interviews and wondering how to solve the longest common prefix in a given array of String problems in Java then you have come to the right place. Earlier, I have shared 21 String programming problems and one of them was this one. In this article, I am going to show you how to solve this frequently asked coding problem from Java Interviews. It's one of the difficult coding problems and not every programmer I have interviewed has solved this, only a few can solve this so preparing for this one can definitely improve your chances and give you a competitive edge over other candidates.

How to check if a node exists in a binary tree or not in Java? Example Tutorial

Hello guys, if you are wondering how to check if a given node exists in a given binary tree or not then you have come to the right place. I have been sharing a lot of binary tree-based programming interview questions in the past few articles. Earlier, we have solved how to find the maximum sum level in a given binary tree, how to find the lowest common ancestor, and how to find Kth smallest element, and in his article, we will solve another classical binary tree problem of search nodes.  Bug, before finding if a node exists in a binary tree or not. It is good to understand what is a  binary tree and binary search tree and how to solve a binary tree-based coding problem. 

10 Tools Every Software Engineer Should Learn In 2024

Hello guys, as a software engineer, staying up-to-date with the latest tools and technologies is essential to your success and one way to keep yourself up-to-date is to learn new framework, libraries and tools. Earlier, I have shared 5 Java Frameworks to learn in 2024 and in this article, we will introduce you to 10 tools that every software engineer should learn in 2024. The list includes, both essential and advanced tools from Git and Docker to TypeScript and GraphQL, which you will need in your day to day development, particularly on web development. 

10 examples of crontab commands in Linux

Hello guys, if you are working in Linux or UNIX environment and scheduled any job or script to run at a particular time at everyday like a script to archive log files at midnight or a script to restart your app on Monday morning then you must have come across crontab command in Linux. While there are many solution to schedule jobs in enterprise application like Control M from Bmc Software and AutoSys but the crontab command provides the easiest way to schedule any script in Linux, as you don't need any third party software for scheduling. It's also quite popular, so much so that all the jobs scheduled by crontab is called cron jobs, and that's why I think every developer should know about crontab command and how to use it. 

Top 10 C++ Interview Questions with Answers for 1 to 2 years Experienced

Today, for a change I am not sharing any Java interview questions, but I am sharing a few C++ interview questions. There is a good demand for developers who know both Java and C++, particularly in the investment banking domain, as a lot of high-performance applications like client connectivity, exchange connectivity, and order management systems (OMS) are written in C++. If you know both Java and C++ then you have a great chance to get a job in big investment banks like Barclays, Nomura, Deutsche Bank, and other Wall Street Firms.

Top 50 Microsoft Software Development Engineer Interview Questions

Hello guys, if you are preparing for Microsoft Software Development Engineer interview or in general preparing for FAANG coding interviews and looking for common interview questions for practice then you have come to the right place. Earlier, I have shared best Coding interview courses and books and in this article, I am going to share you some of the frequently asked questions from Microsoft. Most of the things depending upon for which position you are going like technical analyst, software engineer, Java developer, web developer or internship. If you have a computer science degree and if your job involves coding then you can expect following questions, which are mainly collected from engineers who has appeared on on and off campus interviews.

Friday, April 21, 2023

Difference between child and descendent selectors in jQuery in CSS?

Main difference between descendant and child selector in jQuery or CSS is that descendant selector selects all dom elements whether they are its direct children or not, on the other hand child selector only select direct childrens. Its very easy to understand if you know meaning of descendant and child. For example, my daughter is both my child and descendant but my granddaughter is not my child but descendant. Same definition work in both CSS and jQuery world Since jQUery got his selector from CSS itself, any difference between descendant and child selector which is valid for CSS is also valid for jQuery, unless otherwise stated. Now, lets understand this in terms of DOM elements

Top 12 Java NIO Interview Questions Answers for 5 to 10 Years Experienced Programmers

Hello guys, I have been sharing a lot of Java interview question in this blog and so far I have shared Java interview questions on Core Java, Collections, Java 8, Multithreading, design patterns, Garbage Collections, Spring Framework, Hibernate, SQL and many other topics, but I haven't share many questions on Java NIO, one of the most underrated topic for Java Interviews. Java NIO is very important not just for interviews but also for writing high-performance server side Java application. It is newer and better addition of Java IO and introduced for better performance reason. 

Top 30 Advanced Java Interview Questions for Experienced Developers

Hello guys, I have shared a lot of questions from Java Interviews in this article, so much so that many of my reader search Javarevisited for any Java interview question they come across. While In the past, I have shared Java concurrency questions, Java collections questions, Java questions on design patterns, and many tricky Java questions but a lot of people asked me to share more practical questions for experienced Java developers. Means, more advanced Java questions for 5 to 7 and even 10 years of experienced Java developers. 

Top 20 DevOps Interview Questions with Answers for Experienced Developers

Hello guys, if you are preparing for DevOps Engineer job interview or a Developer interview then preparing DevOps questions is quite important. I have seen a couple of DevOps related questions on Java developer interview in last a couple of years. Interviewers are now expecting you to become familiar with Cloud, DevOps and essential DevOps tools like Docker, Kubernetes, Ansible, Terraform tec. If you have been moving around looking for a way which will help you pass your DevOps interview that is around the corner, you have come to the right place at the right time. 

Top 20 PL/SQL Interview Questions with Answers

Hello guys, if you are preparing for Oracle or PL/SQL Job or a Developer job where PL/SQL skills are needed and looking for frequently asked PL/SQL Interview Questions then you have come to the right place. Earlier, I have shared both best PL/SQL courses and best PL/SQL books and in this article, I am going to share popular PL/SQL Interview Questions you can revise before your interview. Preparing for PL/SQL Interview is not a rocket science and you can prepare for it the same way you prepare for other interviews. 

Top 21 Groovy Interview Questions with Answers for Java developers

Hello guys, if you are preparing for Groovy Developer interview or a Java Developer interview where Groovy is mentioned as required skill then you should prepare for it. If you are looking for common Groovy Interview questions and their answers then you have come to the right place. Earlier, I have shared best Groovy books and online courses to learn Groovy and in this article article, I am going to share frequently asked Groovy Interview Questions with answers.  These Groovy questions covers essential features of Groovy programming language and suitable for both beginners and programmers with 1 to 3 years of experience. 

Top 20 Apache Spark Interview Questions and Answers

As a Big Data specialist, it's critical that you understand all of the words and technologies associated with the area, including Apache Spark, which is one of the most prominent and in-demand Big Data technologies. With the IT industry’s increasing need to calculate big data at high speeds, it’s no wonder that the Apache Spark mechanism has earned the industry’s trust. Apache Spark is one of the most common, general-purpose, and cluster-computing frameworks. There are many common interview questions which is related to apache sparks. Let's have a look at each of them with explanations. 

Top 20 Oracle Database Interview Questions with Answers for 3 to 5 Years Experienced

Hello guys, if you are a developer or a database administrator and preparing for Oracle database interview and need common Oracle database questions for 1 to 5 years experienced then you have come to the right place. Earlier, I have shared tricky SQL query interview questions as well as popular database interview questions and in this article, I am going to share popular Oracle interview questions with answers. If you have used Oracle database for a couple of years or worked as Oracle database administrator then most likely you will know answers of all these questions but if you struggle to answer them then you can always go back and checkout these best Oracle database online courses to learn and revise key Oracle database concepts. 

Top 21 Python Interview Questions Answers for 1 to 2 Years Experienced Programmers

Hello guys, if you are new to programming world, looking for your first Job in software development, particularly for Python developer, and looking for frequently asked Python interview questions then you have come at the right place. Earlier, I have shared best Python courses, books, Python projects, best place to learn Python and many interview questions on Data Structure, System Design, OOP Programming, and Recursion, which are essential topic for any programming interviews, including Python Developers and Engineers and in this article, I am going to share Python questions. These are the questions about Python programming language, Python tools, and Python eco-system in general.

Top 21 Git Interview Questions and Answers for Programmers and DevOps

Hello guys, if you are preparing for Software developer interview then you should prepare for Git, one of the essential and most popular version control and source control tool in Software industry. Almost every company, both big and small are now using Git to store their source code and conduct code reviews, yes the code review is one of the main reason many organization shifted to Git. Both Github and BitBucket provides in-built code review features which also promote good software development practices. 

Top 18 CSS Interview Questions and Answers for 1 to 2 years experienced

Hello guys, if you are preparing for web developer interview then you must prepare for CSS Interview questions. CSS is one of the three core technologies of the World Wide Web(WWW). A website is incomplete without CSS. The first feature of a website noted by the visitors is its presentation. It does not matter how excellent the behind-the-scenes of a website are, if the client-side view is not appealing, the website is almost a failure. Thus, CSS is as important as JavaScript

Thursday, April 20, 2023

5 Difference between Iterator and ListIterator in Java?

The Iterator is the standard way to traverse a collection in Java. You can use Iterator to traverse a List, Set, Map, Stack, Queue, or any Collection, but you might not know that there is another way to traverse over List in Java? Yes, it's called the ListIterator. There are many differences between Iterator and ListIterator in Java, but the most significant of them is that Iterator only allows you to traverse in one direction, I mean forward, you have just got a next() method to get the next element, there is no previous() method to get the previous element. 

HelloWorld Program in Java with Example

First of all, welcome to the exciting world of Java programming. If you are ready to write your first Java program i.e. HelloWorld in Java, it means you already crossed major hurdles to start Java programming, in terms of installing JDK and setting PATH for Java. If you haven't done so then you can follow those tutorials to install JDK in Windows 7 and 8 and setting PATH for Java. Before we start writing HelloWorld in Java, few notes about editors. Many Java beginners insist or try to use Eclipse or Netbeans IDE from the very start of the first program, which is not a good idea. 

Difference between GenericServlet vs HttpServlet in Servlet JSP - J2EE question

Difference between GenericServlet and HttpServlet is one of the classic Servlet Interview Question, asked on many Servlet and JSP Interviews on 2 to 4 years experience developers. Since both GenericServlet and HttpServlet form the basis of Servlets its important to know What are they and What is main difference between them. From common sense and there names, its obvious that GenericServlet is a generic and protocol-independent implementation of Servlet interface while HttpServlet implements HTTP protocol specifics. If you are working in Java web application or J2EE projects, you are most likely to deal with HttpServlet all time as HTTP is main communication protocol of web. In this Servlet JSP article we will outline some important difference between HttpServlet and GenericServlet which is worth knowing and remembering.

How to iterate over HashSet in Java - loop or traverse Example

Iterating over HashSet in Java
Java program to Iterate over HashSet in Java with ExampleIn our last Java collection tutorial, we have seen How to iterate over ArrayList in Java and in this tutorial we will see How to iterate over HashSet in Java. There are two ways to iterate, loop or traverse over HashSet in Java, first using advanced for-each loop added on Java 5 and second using Iterator which is a more conventional way of iterating over HashSet in Java. Now questions are When should you use for loop and when Iterator is an appropriate option. Well I usually use for loop If I only read from HashSet and doesn't remove any element, while Iterator is preferred approach. You should not remove elements from HashSet while iterating over it in for loop, Use Iterator to do that.

How to Fix java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7 [Solved]

Hello guys, today, we'll take a look at the not-so-common error for Java applications. If you have been working in Java for a couple of years then you might have seen this dreaded "java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7" error in your application log or in Eclipse, particularly if you are running your Java application in Java 7. The main cause of this error, "java.lang.VerifyError: Expecting a stack map frame at branch target ... in the method ... at offset 0 error comes when you have some library, JAR file which is only compatible with Java 1.6 or below and you are running your program in JDK 1.7.

When to throw and catch Exception in Java? [Best Practice]

Exceptions are one of the confusing and misunderstood topics in Java, but at the same time, too big to ignore. In fact, good knowledge of Errors and Exception handling practices is one criterion, which differentiates a good Java developer from an average one. So what is confusing about Exception in Java? Well, many things like When to throw Exception or When to catch Exception, When to use checked exception or unchecked exception, should we catch errors like java.lang.OutOfMemoryError? Shall I use an error code instead of an Exception and a lot more? Well, I cannot answer all these questions in one post, so I will pick the first one when to catch or throw any Exception in Java.

How to Fix java.sql.BatchUpdateException: Error converting data type float to numeric - Java + SQL Server

This error can come if you are inserting or updating a NUMERIC column in the Microsoft SQL Server database from a Java Program using the executeUpdate()method, I mean executing a  batch update query. It could also happen if you are calling a stored procedure and passing a float value corresponding to a NUMERIC column, and the value happened to be out-of-range like generating "Arithmetic overflow error converting numeric to data type numeric" on the SQL Server end. For example, if your column is defined as NUMERIC (6,2) the maximum value it can represent is 9999.99, not 999999.99

How to Fix SQLServerException: The index is out of range? JDBC Example

I was executing a stored procedure against SQL SERVER 2008 database from Java program using CallableStatement, but unfortunately, I was getting the following error "SQLServerException: The index 58 is out of range". Since I am passing a lot of parameters I thought that something is wrong with a number of parameters I was passing to the stored proc. My stored procedure had 58 INPUT parameters, as soon as I removed the 58th INPUT parameter the error goes away, which confirmed my belief that SQL Server supports a maximum of 57 INPUT parameters in stored procedure via JDBC

How to deal with java.lang.NullPointerExceptionin Java? Cause, Solution, and Tips to avoid NPE

Hello Java programmers, if you want to learn what is NullPointerExcpeiton in Java and how to deal with NullPointerException or NPE then you have come to the right place. NullPointerException in Java is an unchecked Exception defined in java.lang package and comes when a member of an object either field or method is called on an object which is null. null is a keyword in Java that means nothing and the calling method on an object whose value is null will result in NullPointerException. Since the default value of Object is null, if you call any method or access any field on an Object which is not initialized will throw NullPointerException

How to solve java.sql.BatchUpdateException: String or binary data would be truncated in Java JDBC? [Solution]

Recently I was working in a Java application that uses Microsoft SQL Server at its backend. The architecture of the Java application was old i.e. even though there was heavy database communication back and forth there was no ORM used like no Hibernate, JPA, or Apache iBatis. The Java application was using an old DAO design pattern, where the DB related classes which are responsible for loading and storing data from the database was calling the stored procedure to do their job. These stored procedures take data from Java applications and insert it into SQL Server tables.

How to deal with Unsupported major.minor version 55.0, 57,0, 60.0, 61.0 in Java + Eclipse + Linux [Solution]

The "unsupported major.minor version 55.0" error started to come after Java SE 11 release and the root cause of this error is trying to run a Java application compiled with JDK 11 into a JRE lower than Java SE 11 like JRE 9 or JRE 8. This is very common because a developer has updated their compiler or IDE to Java SE 11 but many times their runtime is not upgraded to Java 11. If you remember, in Java you can run a class file compiled with a lower version say Java 8 to a higher version say JRE 11 because Java is backward compatible but vice-versa is not allowed. I mean, you cannot run a JAR file or class file created by Java 11 version into  Java 8 or Java 9 version. Similarly, you cannot run a Java SE 17 compiled class file in Java SE 11 or Java SE 13 runtime environment.

How to Fix java.lang.NoClassDefFoundError: org/dom4j/DocumentException [Solution]

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException comes when your program is using the DOM4j library but necessary JAR is not present. This error can also come when you are indirectly using the DOM4j library like  when you use the Apache POI library to read the XLSX file in Java,  this library needs dom4j.jar in your classpath. Not just this one but there are several other libraries that use this JAR internally, if you are using any of them but don't have this JAR then your program will compile fine but fail at runtime because JVM will try to load this class but will not be able to find it on the classpath

[Solved] Exception in thread "main" java.lang.IllegalStateException during Iterator.remove() in Java

Hello guys, if you are wondering how to deal with  java.lang.IllegalStateException while trying to remove elements from ArrayList in Java then you have come to the right place. In this article, I am going to share how I solved this problem and how you can do the same. I was writing a sample program to demonstrate how to remove elements from the list while iterating over it by using the Iterator.remove() method. Unfortunately, I was getting the following error, right at the place where I was calling the Iterator.remove() method :

Wednesday, April 19, 2023

What is Synchronized Keyword and Method in Java? Example

synchronized keyword in Java is one of the two important keywords related to concurrent programming in Java, the other being a volatile keyword. the synchronized keyword is used to provide mutual exclusion, thread safety, and synchronization in Java. Unlike Volatile keyword, synchronized keyword is not an application to instance variable and you can only use synchronized keyword either with synchronized method or block. synchronized keyword work with the concept of lock, any thread which holds a lock on which synchronized method or block is locked, can enter otherwise thread will wait till it acquires the lock. In Java programming language every object holds a lock and every class holds a lock, like two String objects s1, s2 holds two different object lock,s and String.class is used to represent class lock.

How to use DROP command to remove tables in Oracle, MySQL and SQL Server

Hello guys, if you want to learn about DROP command in SQL then you have come to the right place. Earlier, I have shared the best free SQL and Database courses and several tutorials to learn SELECT, GROUP BY, and other important commands, and in this article, I will show you to use the DROP command in SQL. DROP is one of the basic SQL commands, which is used to DROP database objects. Since it's part of ANSI SQL, the DROP command is supported by all major database vendors, including Oracle, MySQL, and Microsoft SQL Server. A SQL DROP TABLE statement is used to delete a table definition and all data from a table, but DROP can also be used to drop index, view, trigger, or any other database object. 

[Solved] Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number in Java and Oracle

Hello guys, if you are getting below error in your Java program and wondering how to solve this or just stuck then you have come to the right place. In this article, I will explain to you what causes the " java.sql.SQLSyntaxErrorException: ORA-01722: invalid number" error when you connect to an Oracle database from a Java program and how you can solve it. 

But, first of all, let's take a look at the stack trace of this error which looks like below:

10 Essential SQL Commands and Functions Every Developer should learn

Hello guys, if you are starting with SQL and wondering which commands you should learn first then you have come at the right place. In this article, I have shared 10 most essential SQL commands and functions which I believe every programmer should learn. This includes commands to pull data from database as well write data into data, update data, and remove data from database. While writing in the SQL language, you will utilize an assortment of SQL keywords to make explanations and questions. An assertion includes a series of characters and SQL keywords that adjusts to the designing and grammar rules of the language and may influence information or control processes corresponding to your information. 

How to convert String to Integer SQL and Database? MySQL, Oracle, SQL server and PostgreSQL Example

 Hello guys, if you are wondering how to convert VARCHAR to String in SQL then you are at the right place. In this article, we will cover various techniques to convert String to Integer in all databases - MySQL, Oracle, SQL server and PostgreSQL. To perform tasks or correlations or change between information in a SQL Server data set, the SQL information kinds of those values should coordinate. At the point when the SQL information types are unique, they will go through a cycle called type-projecting. The transformation of SQL information types, in this cycle, can be implied or unequivocal.

What is Normalization in SQL? 1NF, 2nd NF, 3rd NF and BCNF Example Tutorial

What is Normalization?
Normalization is one of the essential concept of relational database. It is the process or technique to remove duplicate data from tables and thus reduce the storage size. It also helps to maintain integrity of data. Normalization likewise assists with coordinating the information in the data set. It is a multi-step process that sets the information into even structure and eliminates the copied information from the relational tables. Normalization coordinates the segments and tables of a data set to guarantee that data set integrity constraints appropriately execute their conditions. It is an orderly method of deteriorating tables to take out information overt repetitiveness (redundant) and unfortunate qualities like Insertion, Update, and Deletion anomalies.

What is temporary table in Database and SQL? Example Tutorial

Hello folks, if you have heard the term temporary table online or by your colleague in a call and wondering what is temporary table, what is the difference between a normal table and a temporary table, and when and how to use it then you have come to the right place. In this blog, we shall learn how to use a temporary table in SQL. But before we go into that we need an overview of SQL. What is SQL? SQL stands for Structured query language. it is a programming language used in communicating or relating to the relational database. And this programming language performs various forms of operation in the data. It was created in the 1970s, SQL is used by database administrators, and developers writing data integration scripts, etc.

How to use EXISTS and NOT EXISTS in SQL? Microsoft SQL Server Example

Hello guys, if you are wondering how to use the IF EXISTS and NOT EXISTS in SQL then you are at the right place. Earlier, I have shared how to use GROUP BY, WHERE, and HAVING clause and in this tutorial I will share how to use exists and not exists clause in SQL. The IF EXISTS and NOT EXISTS commands in T-SQL are covered in depth in this article. When comparing data sets using subqueries, it also illustrates why EXISTS should be preferred over IN and NOT EXISTS over NOT IN. If you don't know, EXISTS is a logical operator in SQL that is used to check if rows in a database exist. If the subquery produces one or more records, it returns TRUE. The NOT EXISTS operator in SQL is the polar opposite of the EXISTS operator, and it is fulfilled if the subquery returns no results.

Tuesday, April 18, 2023

Top 21 Web Development Interview Questions with Answers

Hello guys, if you are preparing for web developer job and looking for popular web development interview questions for preparation then you have come to the right place. Earlier, I have shared HTML Interview Question, CSS Interview Questions, and JavaScript Interview Questions and in this article, I am going to share common web development interview questions. You may be thinking how much different it is from other list but this is a general questions about web development like web services, images, SOAP, REST, Pagination etc.

Top 20 Cyber Security Interview Questions and Answers

Hello guys, if you are preparing for Cyber Security Engineer Job interviews and looking for frequently asked Cyber Security Interview questions with answers then you have come to the right place. Earlier, I hare shared best Cyber Security online courses and best Ethical Hacking online courses and in this article, I am going to share 20 common Interview Questions for Cyber Security Professionals. These interview questions are great to revise key Cyber Security concepts, tools, and process before you go for any interview. 

Top 20 Cloud Computing Interview Questions and Answers

Hello guys, if you are preparing for Java developer interview or DevOps Engineer Interview, or a System admin, , knowledge of Cloud Computing is mandatory nowadays. It's even more important if you are interviewing for Cloud Engineer. Earlier, I have shared best Cloud Computing Courses and Books and today, I am going to share 20 Cloud Computing Questions for interviews. You can use these questions to revise essential Cloud Computing Concepts before interviews. If you are new to Cloud Computing space then these questions are also good to learn more about Cloud Computing by doing research.

Top 20 Project Management Interview Questions and Answers

Hello guys, if you are preparing for project manager interview and looking for frequently asked Project Management interview questions with Answers then you have come to the right place. In the past, I have shared best books and courses to learn Project Management, including best PMP courses to prepare for popular Project Management Professional Certification and in this article, I am going to share 20 common Project Management related questions from Interviews. But, before we get to some of the most important and frequently asked Project Management interview questions, let me tell you a little bit about what Project Management is.

Top 20 AWS Interview Questions Answers for Developers and DevOps Engineers

Hello guys, if you are preparing for Cloud engineer interview or preparing for a developer role where AWS cloud skills are required and need AWS questions to kick start your preparation then you have come to the right place. Earlier, I have shared 20 Cloud Computing Interview Questions with answers and in today's article, I am going to share 20 common AWS questions with answers from interviews. These questions are suitable for 1 to 3 years experienced AWS professionals as it touches fundamental AWS concepts and services. If you have worked on AWS platform then most likely you can answer all of these questions but if you struggle then you can always go back and join one of these best AWS cloud courses to learn and revise key AWS concepts before interviews. 

Top 51 JavaScript Interview Questions for 1 to 2 Years Experienced Developers

Hello guys, you may know that JavaScript is one of the most popular programming languages, having ranking #1 for a couple of years in the StackOverflow survey. There is no doubt that JavaScript is the most popular language or web development. The best thing is that you can use JavaScript to develop both frontend and backend using the same programming language and tech stack. You have so many popular frameworks like React.js, Angular, Node.js, Vue.js to implement sophisticated web applications for different domains. That's why the demand for JavaScript developers is very high, especially full-stack JavaScript developers who can create front-end and back-end applications independently.

Top 50 Advanced Java Garbage Collection and Performance Interview Questions and Answers

Hello Java Developers, If you have gone through any Java Developer interview, particularly for a senior developer role then you know that a good knowledge of JVM internals and Garbage collection is important. Even though Java and JVM take care of memory management for you, bad code can still cause memory leaks and performance issues. For example, if you are creating millions of objects in a loop or keeping an un-intended reference of dead objects then you are putting additional strain on the Garbage collector and creating a memory leak in your application. You cannot blame Java and JVM for that and the only way to avoid such errors is to know about how Garbage collection works.

Top 50 Database and SQL Interview Questions Answers for Programmers

Hello guys, whether you are preparing for Java developer interview or any other Software Developer Interview, a DevOps Interview or a IT support interview, you should prepare for SQL and Database related questions. Along with Data Structure, Algorithms, System Design, and Computer Fundamentals, SQL and Database are two of the essential topic for programming or technical Job interview. In the past, I have shared many questions related to MSSQL questions, Oracle Questions, MySQL questions, and PostgreSQL questions and in this article, I am going to share both theory based and query based Database and SQL Interview questions with to the points answers.

Top 27 Spring Security Interview Questions Answers for Java Developers

Hello guys, if you are preparing for Java and Spring Developer interview then you should prepare about Spring Security. Since Security is an important topic and Spring security is the most popular framework to implement security in Java web applications, there is always a few questions based upon Spring Security in Java developer interviews. In the past, I have shared Spring Boot questionsSpring Data JPA Question, Spring Cloud Questions, and Microservices Interview Questions and in this article, I will share 20 popular Spring security questions for practice. I have also shared answers so that you can revise key Spring security concepts quickly but if you think that you need more preparation on certain topic then you can also checkout this list of best Spring Security courses where I have shared online courses to learn Spring security in depth. 

Top 20 Jenkins and CI/CD Interview Questions Answers for Java Developers

Hello guys, if you are preparing for Java developer interview or DevOps Interview, one tool which you should know well is Jenkins, the king of Continuous Integration and Continuous build, and one of the most desirable skill companies look on experienced programmers now a days. Earlier, I have shared best free Jenkins courses for programmers to learn this useful tool as well as Interview questions on DevOps, Docker, and Kubernetes and in this article, I am going to share 20 frequently sked Jenkins and CI/CD Interview questions with answers for both beginners and experienced developers. 

Top 20 Agile and Scrum Interview Questions and Answers for PM, Programmers and Testers

Hello guys, ,if you are preparing for Software Developer interview then it makes to prepare questions on Agile and Scrum methodology. Agile is the standard way to develop software and most of the companies, both big and small follows Agile to develop and deliver Software. Earlier, I have shared free Agile and Scrum online courses to learn these useful technologies for Software development and today, I am going to share 20 Agile and Scrum interview questions with answers. But, before we get to the all-important interview questions that will help you land your dream software job, let me tell you something about Agile and Scrum. 

Monday, April 17, 2023

How to use Recursion in JavaScript? Example Tutorial

If you are a programmer, you may have come across a term called “recursion”. In programming, several techniques are used to solve a problem. Recursion is one such technique. It allows you to break a big problem into smaller parts and then solve those smaller parts. It's also one of the useful techniques to solve dynamic programming-based problems and that's why it's very very important for any programmer or developer preparing for coding interviews.  Recursion is not limited to a specific programming language. It can be performed using Java, JavaScript, C, or any other programming language. In this article, we will learn what is recursion and how to perform it using JavaScript.

What is HashSet in Java? Example Tutorial

Hello guys, we meet again for our journey of learning Java. Today, we are gonna learn something very fruitful and easy. Hope you all are excited and ready. I would recommend you guys to go through the HashMap or TreeMap article which goes over hashing as this topic has some of its features. So, What's the wait? Let's start! Suppose you guys are given the task of storing car names (yes, I love cars :p). Now, how would you store it? If you guys have some questions, here are the requirements. The car names may increase over time. So, logically, an array is not what we are looking for. 

What is Blocking Deque in Java? How and When to use BlockingDeque? Example Tutorial

Hello friends, we meet again here today on our journey to Java. Before we continue forward, let me inform you guys that today's topic is in continuation of our Java Deque topic. If any of you guys have not read the Java Deque tutorial, go ahead and read that one first. Though there is no such limitation of this article, it is recommended to have gone through the basics of Deque and our previous post. So, I guess now we will continue our Deque topic and today we will discuss something very interesting. Today we are gonna jump into the advanced topic of Deque and how we can leverage the functionality Java has provided for a better and more robust application building.

How to find 2nd, 3rd or kth element from end in linked list in Java? Example [Solved]

Hello guys, today, I am going to discuss one of the important linked list based coding problems from interviews - how to find the Kth element from the end? This question is also asked as to how do you find the 3rd element from the last of a singly linked list in one pass or write a Java program to find the 5th element from the tail of a given linked list in one iteration. In this article, you will learn the programming technique so that you can solve any variant of this problem, I mean the Kth node from the tail problems and some linked list-based challenges. The difficulty in this question is that you need to solve the problem in one iteration or one pass. This means you cannot traverse the linked list again. I mean you cannot go till the end then traverse back to the Kth element.

10 Examples of an Array in Java

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

Top 40 Perl Interview Questions and Answers for Programmers

Hello guys, if you have been working as a professional Software developer then you may have heard about Perl, one of the most powerful scripting languages. Perl is really great when it comes to creating reports, write scripts to analyze text, and connect to DB, load data and generate reports. Perl is even more important for IT support professionals, business analysts, and IT professionals who need to work in the field of operations. That's why Perl questions are quite common during Software developer and IT support interview, especially if the Job description mention Perl or you have added Perl as a skill in your resume or LinkedIn Profile.

3 Examples of flatMap() of Stream in Java

Hello guys, if you are doing Java development then you must have come across the flatMap() method on Stream and Optional Class. The flatMap() method is extension of map() function as it does both flattening and mapping (or transformation) instead of just transformation done by map() method. I have explained the difference between map() and flatMap() earlier in detail, but just to revise, let's revisit it. If you have a list of String e.g. {"credit", "debit", "master", "visa"} then you can use the map() method to get a list of integer where each value is length of corresponding String e.g. list.stream().map(s -> s.length()) will produce {6, 5, 6, 4}. This is called transformation because you have transformed an stream of String to a Stream of integer

Saturday, April 15, 2023

How to fix cannot determine embedded database driver class for database type NONE

Hello and welcome to the blog post. Today we are going to take a look at a frequently encountered problem in Spring Boot Application. If you are reading this, I'm going to assume that you saw the problem "Cannot determine embedded database driver class for database type NONE" while executing a Spring Boot application. We will understand, when this error appears. For this we will create a simple Spring Boot project as shown below. It demonstrates how I encountered the problem "Cannot determine embedded database driver class for database type NONE".  

Friday, April 14, 2023

Write a Program to Find Sum of Digits in Java

One of the common programming practice question thrown to beginners is to write a program to calculate the sum of digits in an integral number. For example, if the input is 123456 then output or sum of the digit is (1+2+3+4+5+6) = 21. An additional condition is you can not use any third party or library method to solve this problem. This program is not as simple as it looks and that's why it's a good exercise, you must know some basic programming techniques e.g. loops, operators, and logic formation to solve this problem. Let's see how we can solve this problem using Java programming language. In order to calculate the sum of digits, we must get digits as numbers. So your first challenge is how do you get the digits as numbers?  How do we extract 6 out of 123456?

How to use Multiple Catch block for Exception handling in Java? Example Tutorial

Java 7 in many ways improved exception handling. Two of the feature of Java 7 which improves exception handling are the ability to catch the multiple exceptions in one catch block and closing resources automatically using Automatic resource management block. Java has long been criticized for its verbose exception handling code, mandatory to handle checked Exceptions in Java. Programmers always complained that it clutters the code and reduced readability. Java 7 somehow reduces this pain by improving the Exception handling feature e.g. multiple catches and ARM blocks. In this Java 7 tutorial, we will see how to catch multiple exceptions in one catch block using JDK7.

How to format Date in Java - SimpleDateFormat Example

SimpleDateFormat in Java is used to format Date in Java. You can format date on any String format based upon various attribute available in SimpleDateFormat class e.g. mm, dd, YY etc. You can also put timezone information in formatted Date using Z attribute of DateFormat class. SimpleDateFormat is sub class of DateFormat and provide format() and parse() method to convert Date to and from String in Java. Worth noting is that SimpleDateFormat is not thread-safe and should not be shared with others. Avoid using static SimpleDateFormat in Java classes. If you want to share SimpleDateFormat or want to make it thread-safe, you can use ThreadLocal variable in Java to avoid sharing SimpleDateFormat among multiple threads. parse() method of SimpleDateFormat throws ParseException if String input is not a valid date or can not be parsed into mentioned format.

Difference between URL, URI and URN - Interview Question

All three URI, URL, and URN are used to identify any resource or name on the internet, but there is a subtle difference between them. URI is the superset of both URL and URN. By the way, the main difference between URL and URI is protocol to retrieve the resource. URL always include a network protocol e.g. HTTP, HTTPS, FTP etc to retrieve a resource from its location. While URI, in case of URN just uniquely identifies the resource e.g. ISBN numbers which are a good example of URN is used to identify any book uniquely. In this article, we will briefly see what is URI, URL, and URN and then see the main difference between URI, URL, and URN.

How to traverse iterate or loop ArrayList in Java

How to Loop ArrayList in Java
Iterating, traversing or Looping ArrayList in Java means accessing every object stored in ArrayList and performing some operations like printing them. There are many ways to iterate, traverse or Loop ArrayList in Java e.g. advanced for loop, traditional for loop with size(), By using Iterator and ListIterator along with while loop etc. All the method of Looping List in Java also applicable to ArrayList because ArrayList is an essentially List. In next section we will see a code example of Looping ArrayList in Java.

How to use Java Enum in Switch Case Statement - Exampel Tutorial

Java Enum in Switch Case Statement
Yesterday, someone ask me Can we use Java Enum in Switch case? Obviously, he was learning Enum and not aware that How powerful Enum in Java is. Yes, You can use Enum in Switch case statement in Java like int primitive. If you are familiar with enum int pattern, where integers represent enum values prior to Java 5 then you already knows how to  use the Switch case with Enum. Using Java Enum in the Switch case is pretty straightforward, Just use Enum reference variable in Switch and Enum constants or instances in CASE statement. In this Java tutorial we will see one example of How to use Enum in Switch statement in Java

What is CopyOnWriteArrayList in Java - Example Tutorial

CopyOnWriteArrayList vs ArrayList in Java
CopyOnWriteArrayList is a concurrent Collection class introduced in Java 5 Concurrency API along with its popular cousin ConcurrentHashMap in Java. CopyOnWriteArrayList implements List interface like ArrayList, Vector, and LinkedList but its a thread-safe collection and it achieves its thread-safety in a slightly different way than Vector or other thread-safe collection class. As the name suggests CopyOnWriteArrayList creates a copy of underlying ArrayList with every mutation operation e.g. add, remove, or when you set values. That's why it is only suitable for a small list of values which are read frequently but modified rarely e.g. a list of configurations.

Difference between Error vs Exception in Java - Interview question

Both Error and Exception are derived from java.lang.Throwable in Java but main difference between Error and Exception is kind of error they represent. java.lang.Error represent errors which are generally can not be handled and usually refer catastrophic failure e.g. running out of System resources, some examples of Error in Java are java.lang.OutOfMemoryError or Java.lang.NoClassDefFoundError and java.lang.UnSupportedClassVersionError. On the other hand java.lang.Exception represent errors which can be catch and dealt e.g. IOException which comes while performing I/O operations i.e. reading files and directories.

Java program to get SubList from ArrayList - Example

Sometimes we need subList from ArrayList in Java. For example, we have an ArrayList of 10 objects and we only need 5 objects or we need an object from index 2 to 6, these are called subList in Java. Java collection API provides a method to get SubList from ArrayList. In this Java tutorial, we will see an example of getting SubList from ArrayList in Java. In this program, we have an ArrayList which contains 4 String objects. Later we call ArrayList.subList() method to get part of that List.