How to read Properties file in Java
If you have any configurable data in your application like DB configuration, user settings its better to keep it in a properties file. A properties store data in a form of key/value pair.In this...
View ArticleJava Stream API Interview Questions
What is Stream API in Java?Stream API is added in Java 8 and works very well in conjunction with lambda expressions. You can create a pipeline of stream operations to manipulate data by performing...
View ArticleHow to Create Your Own BlockingQueue - Java Program
This post shows how you can create your own BlockingQueue using ReentrantLock and Condition interface. Condition interface provides method await and signal which work the same way as wait and...
View ArticleHow to Format Time in AM-PM Format - Java Program
In this post I’ll show how you can format time in AM-PM format.In order to get time in AM-PM format, in the format you are creating using SimpleDateFormat (if you are not using Java 8) or DateFormatter...
View ArticleIf Given String Sub-Sequence of Another String - Java Program
I recently remembered one interview 6-7 years back where I was asked to write a Java program to find if given stringis the subsequence of another string. I started writing the program but my approach...
View ArticleJust In Time Compiler (JIT) in Java
When we start studying Java we get to know one of the prominent feature of Java is that Java is platform independent.How platform independence is achievedIn a short sentence, Java is platform...
View ArticleHow to Find Common Elements in Two Arrays - Java Program
This post is about writing a Java program to find common elements in the given arrays. It is a common interview question where it is asked with a condition not to use any inbuilt method or any inbuilt...
View ArticleThread Starvation in Java Multi-Threading
In any multi-threaded application, where you have multiple threads vying for the access over the shared resources you may come across a situation where a thread (or a bunch of threads) is unable to...
View ArticleHow to Find First Non-Repeated Character in a Given String - Java Program
A very popular interview question for String is “Find first non-repeated character in a given String”. As example if given string is “always” then first non-repeated character is ‘l’ as character ‘a’...
View ArticleJVM Run-Time Data Areas - Java Memory Allocation
The Java Virtual Machine(JVM) defines various run-time data areas that are used during the execution of the program. Some of these data areas are created per thread where as others are created on JVM...
View ArticleArrange Non-Negative Integers to Form Largest Number - Java Program
In this post, we’ll see Java code to solve the stated problem “Given a list of non-negative integers arrange them to form a largest number”.As example– If list of non-negative integers is [2, 35, 23,...
View ArticleHeap Memory Allocation in Java
In the post JVM run-time data areas we have already got a brief idea about the memory areas used while running a Java application. In this post we’ll talk about Heap memory space in detail – How Heap...
View ArticleDifference Between Two Dates - Java Program
In this post we’ll see how to calculate date-time difference between two dates in Java using the new date and time API in Java 8 -Using Java 8 Period and Duration classesIf you are using Java 8 then...
View ArticleFind Largest and Second Largest Number in Given Array - Java Program
This post is about writing a Java program to find the top two numbers (largest and second largest) in the given array.Condition here is that you should not be using any inbuilt Java classes or methods...
View ArticleFind Largest and Smallest Number in the Given Array - Java Program
This post is about writing a Java program to find the largest and the smallest number in the given array or it can also be rephrased as - Find the maximum and minimum number in the given...
View ArticleGarbage Collection in Java
In the post Heap Memory Allocation in Java I have already explained why heap is divided into generations and how it helps in garbage collection by adopting an approach known as “generational...
View ArticleFind Maximum and Minimum Numbers in the Given Matrix - Java Program
This post is about writing a Java program to find the maximum and minimum number in the given matrix (2D Array).Solution to find largest and smallest numberLogic here is to have two variables for...
View ArticleLivelock in Java Multi-Threading
Livelock in Java multi-threading is a situation where two or more threads are acting on a response to an action of each other and not able to make any progress because of that.How livelock is different...
View ArticleTypes of JDBC Drivers
JDBC driver is an implementation of the Driverinterface in the java.sqlpackage.Every database vendor should provide a JDBC driver for their DBMS and each JDBC driver should supply a class that...
View ArticleJava JDBC overview - JDBC Tutorial
JDBC is the Java API for developing Java applications that access relational databases.Why use JDBCJDBC provides developers with a uniform interface to connect with different relational databases like...
View Article