Check a String is a Pangram in Java

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 given alphabet at least once….

Find All Paths from Root to Leaf Nodes in Binary Tree using 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 parent. Every node in a…

Java To Find Common, Uncommon, Unique Elements In ArrayLists

Elements in ArrayList 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 but for…

Merge Two String Arrays and Produce Unique Values using Java

Unique elements by merging arrays In this tutorial, I will show you how to merge string values from two arrays and produce the final array with unique string values. I 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 appear…

Find Closest Number from Array to the Given Number in 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

How to check or make a number palindrome 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 equal to its reversed counterpart….

How to find longest substring without repeating characters using 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 words separated by spaces.

How to shuffle an ArrayList 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 we will basically swap or…

Reverse A String Without Affecting Special Characters Using Java

String with special characters 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 want to…

Find largest product of two elements in an array 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 element may be 0 or…