
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 67 Articles for Campus Interview

703 Views
In this article, we will learn to sort ArrayList of custom objects by property in Java. The ArrayList class extends AbstractList and implements the List interface. ArrayList supports dynamic arrays that can grow as needed. Problem Statement ArrayList is created with an initial size. When this size is exceeded, the collection is automatically enlarged. When objects are removed, the array may be shrunk. Below is a demonstration of the same − Input − The list is defined as Java Scala Python Mysql Output − The list after sorting values: Java Mysql Python Scala ... Read More

1K+ Views
In-order traversal processes each node by visiting the left subtree first, then the node, and finally the right subtree. This is particularly useful for certain types of tree structures, such as binary search trees, where in-order traversal will print the values in sorted order. In this article, we will explore how to perform an in-order traversal of a binary tree. Following are the ways to implement in-order traversal in Java: Using Recursion Using Stack (Iteration) Inorder Tree Traversal using Recursion To traverse a tree in order using recursion, we need ... Read More

497 Views
Java HashMap is a hash table-based implementation of Java's Map interface. It is a collection of key-value pairs.In this article, we will learn to sort a map by values in Java. Following are the ways to sort a map by values in Java: Using Comparator Using Streams Using Comparator We can sort a map by values using a custom comparator. The comparator will compare the values of the map entries and sort them accordingly. Steps to sort a map by values using Comparator: Step 1: Create a HashMap and populate it with some key-value pairs. Step 2: ... Read More

473 Views
In this article, we will understand how to merge two lists. A list is an ordered collection that allows us to store and access elements sequentially. It contains the index-based methods to insert, update, delete and search the elements. It can also have the duplicate elements.Below is a demonstration of the same −Suppose our input is −First list: [45, 60, 95] Second list: [105, 120]The desired output would be −The list after merging the two lists: [45, 60, 95, 105, 120]AlgorithmStep 1 - START Step 2 - Declare three integer lists namely input_list_1, input_list_2 and result_list. Step 3 - Define ... Read More

953 Views
In this article, we will learn to initialize a list in Java. A list is an ordered collection that allows us to store and access elements sequentially. It contains index-based methods to insert, update, delete, and search the elements. It can also have duplicate elements. Problem Statement Given a scenario where you need to create and initialize a list in Java, the goal is to understand and implement various approaches to initialize lists effectively. Input Initialize an empty list and add elements − "Apple", "Banana", "Cherry" Output ["Apple", "Banana", "Cherry"] Different Approaches Following are the different approaches to Initialize ... Read More

465 Views
The List extends Collection and declares the behavior of a collection that stores a sequence of elements. The Collection is a framework that provides architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion. In this article, we will learn to rotate elements of a list in Java. Rotating a list means shifting the elements of the list either to the left or to the right. Following are the ways to rotate elements of a list in Java: ... Read More

2K+ Views
In this article, we will understand how to find all the subsets of a string. In Java, String is a datatype that contains one or more characters and is enclosed in double quotes(“ ”). A part or a subset of string is called substring. Example Scenario: Input: string = JVM; Output: The subsets of the string are: J, JV, JVM, V, VM, M Finding all Subsets of a String in Java Use the following approaches to find all subsets of a String in Java − Using nested for Loop ... Read More

837 Views
In this article, we will understand how to divide a string into 'N' equal parts using Java. If the string's length is divisible by N, the string will be split evenly into N parts; otherwise, a message will be displayed indicating that the string cannot be divided into N equal parts. This is demonstrated using both a simple main method and an encapsulated approach. Problem Statement Write a program in Java to divide a string into 'N' equal parts. Below is a demonstration of the same − Input Input string: Java Program is fun! Output The length of the string ... Read More

1K+ Views
Minimum and Maximum Values of a ListA list is an ordered collection that allows us to store and access elements sequentially. It contains index-based methods to insert, update, delete, and search the elements. It can also have duplicate elements. The following are the ways to get the minimum and maximum from a list in Java: Using Loops Using Collections Using Streams Minimum and Maximum of a List Using LoopsWe can find the minimum and maximum values in a list by iterating through the elements using loops. We will initialize two variables to save the minimum and maximum values, and ... Read More

991 Views
In this article, we will understand how to check if a string is empty or null in Java. The string is a datatype that contains one or more characters and is enclosed in double quotes(“ ”). We’ll start by learning to detect these cases directly within the main method, and then we’ll see how to achieve the same result using encapsulation for better code organization and reusability. Problem Statement Write a program in Java to check if a string is empty or null. Below is a demonstration of the same − Input Input string: null Output The string is a null ... Read More