This example will show you what is a pangram and how to check a string is a pangram in Java program. A string is a pangram if it contains all letters or characters of alphabets (a to z or A to Z). A pangram or holoalphabetic sentence is a sentence using every letter of a…

Posted in Java

Check a String is a Pangram in Java

In this example I am going to show you how to find all paths from root to leaf nodes in binary tree. So I am going to find each path from root to leaf node using Java program. A binary tree is a non-linear data structure type tree with at most two children for each…

Posted in Java

Find All Paths from Root to Leaf Nodes in Binary Tree using Java

Here I am going to show you how to find common, uncommon, unique elements in two Lists or ArrayLists using Java program. In this program I will show you how to find common, uncommon, unique string elements as well as object elements in two ArrayLists. For identifying the unique string elements is very straight forward…

Posted in Java

How to find Common, Uncommon, Unique Elements in Two ArrayLists using Java

Introduction In this tutorial we will show you how to merge string values from two arrays and produce the final array with unique string values. We will use Set data structure to produce the unique results in final array. When passed two arrays of strings, it will return an array containing the string values that…

Posted in Java

Merge Two String Arrays and Produce Unique Values using Java

In this tutorial you will find closest number from array to the given number. Given an array of sorted integers, find the closest value to the given number. The array may contain duplicate values and negative numbers. Examples Array : 2,5,6,7,8,8,9Target number : 5Output : 5

Posted in Java

Find Closest Number from Array to the Given Number in Java

Here we will create an example on how to check a given number is palindrome or not. We will also make the given number palindrome if it is not palindrome. In our other tutorial we have seen how to check a string is palindrome or not. A string or number is palindrome if it is…

Posted in Java

How to check or make a number palindrome in Java

Introduction In this example we will see how to find longest substring from a given string without repeating characters using Java programming language. A given string when broken into substring will have different lengths and we will find the string which has longest length among them. A string may consist of contiguous characters or several…

Posted in Java

How to find longest substring without repeating characters using Java

Introduction In this example we will see how to shuffle an ArrayList using Java programming language. We will use shuffle() method from Collections class to shuffle the ArrayList. We will also create our own method to shuffle the ArrayList. Shuffle means rearrange the elements of the ArrayList by sliding them over each other quickly. So…

Posted in Java

How to shuffle an ArrayList using Java

Introduction In this tutorial you will see how to reverse a string without affecting special characters using Java programming language. You will also see in this example how to check whether a character is alphabet or digit or special character. Your string may contain special characters such as $, #, @ etc. and you don’t…

Posted in Java

How to reverse a String without affecting Special Characters using Java

Introduction In this example we will see how to find largest product of two elements in an array using Java language. In other hand you can also find those two elements for which the largest product is computed among the elements of an array. The elements are assumed to be integer in an array. The…

Posted in Java

Find largest product of two elements in an array using Java

Introduction Here I will create a sample program to count words, paragraphs, sentences, characters, white spaces in a text file using Java programming language. In this tutorial I will read a simple text file and count number of words, paragraphs, characters etc.

Posted in Java

How to count Words, Paragraphs, Sentences, Characters, White Spaces in a Text File using Java

Introduction Here you will see an example on how to group objects by their property using Java 8 stream API. GROUP BY is a very useful aggregate operation in SQL, which allows us to group records on certain criteria and Java 8 or later version of Java directly allows you to do GROUP BY in…

Posted in Java

How To Group Objects By Their Property Using Java 8 Stream