Core java
- 16 October
Custom BlockingQueue implementation in java
In this post, we will see how to create your own custom BlockingQueue. This is one of the most asked java interview questions. You need to implement your own BlockingQueue. This question helps interviewer to get your understanding of multithreading concepts. Here is simple implementation of BlockingQueue. We will use array to store elements in […]
- 05 October
Java FileReader Example
The FileReader class of java.io package provides a seamless and easy-to-use way to read and analyse the contents of a file using Java. The FileReader class, works similar to the FileInputStream class because it reads the file data as a stream. However, unlike the latter which reads files as a stream of bytes, FileReader reads […]
- 30 September
Longest common substring
If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to find the longest common substring in java. Program Given two String, find longest common substring. For example: String 1: Java2blog String 2: CoreJavaTutorial Longest common subString is: […]
- 27 September
Print maximum occurring character in a String
In this post, we will see how to print the maximum occurring character in a String. Problem Print maximum occurring character in a String For example: String 1: java2blog tutorial Character: a has occurred maximum times in String: 3 ———————- String 2: This is test message Character: s has occurred maximum times in String: 5 […]
- 12 August
Intersection of two linked lists
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. In this post, we will see how to find Intersection of two linked lists. Problem Given two singly linked lists, find if two linked lists intersect. If they intersect, find intersection point. Solution Here is simple algorithm to […]
- 10 August
Java Collection to List
In this post, we will see how to convert Java Collection to List. There are many ways to do it, we will see two ways here. Using ArrayList constructor [crayon-67428477aa775823024375/] Above ArrayList‘s constructor creates a list having the elements of the specified collection, in the order they are returned by the collection’s iterator. Using Java […]
- 09 August
Java Collections shuffle
Shuffle method is to permute passed list with default or specified randomness. Syntax [crayon-67428477aa8c0800630082/] Example : Let’s see both the function with the help of example. [crayon-67428477aa8c4169605664/] When you run above program, you will get below output: ========================== Before shuffling [John, Martin, Mohan, Mary, Tom] ========================== After shuffling [Mohan, Martin, Mary, Tom, John] ========================== After shuffling […]
- 08 June
Java Regex for alphanumeric characters
In this post, we will see how to create regex alphanumeric which will create only alphanumeric characters. There are times when you need to validate the user’s input. It should contain only characters from a-z, A-Zor 0-9. Here is simple regex for it. ^[a-zA-Z0-9]*$ Here is the explaination of above regex. ^ : start of […]
- 08 June
Java – Create new file
There are many ways to create a file in java. Creating a file is a very easy task. We will learn 5 different ways to Create a file. Using java.io.File class’s createNewFile method This is simplest and oldest way to create file.Here is simple snapshot to create a file in java. [crayon-67428477aaaea371722732/] Using java.nio.file.Files from […]