
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 33676 Articles for Programming

654 Views
In this article, we will learn to sort maps by keys in Java. In Java, the Map interface provides a collection of key-value pairs where each key is unique. Sorting a map by its keys can be useful when you want to order the elements based on the keys instead of their values. Sorting a Map in Java Java provides different ways to sort a map by keys. A TreeMap, a part of the java.util package is one of the easiest ways to sort a map. It stores the map entries in a natural order (ascending) based on the ... Read More

1K+ Views
In this article, we will understand how to check if a Set is a subset of another set. A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are not allowed. Following are the ways to check if a set is a subset of another set: Using containsAll() Method Using Stream API Using containsAll() Method In Java, the set interface has a method called containsAll() that checks ... Read More

1K+ Views
A Set is a Collection that cannot contain duplicate elements (same as the mathematical set abstraction). The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. Finding the difference between two sets means finding the elements that are not similar in both sets. For example, we have set A = {1, 2, 3} and set B = {2, 3, 4}. The difference between these two sets will be {1, 4} because 1 is not in set B and 4 is not in set A. In this article, we will learn how to ... Read More

486 Views
What is a LinkedList? A Linked list is a sequence of data structures where each node contains two parts as follows - Data: The value or information stored in the node. Next: A reference (or pointer) to the next node in the sequence. Detecting a Loop in a LinkedList A loop or cycle means that the last node of a linked list is connected back to one of the nodes earlier in the list, creating a cycle. Or, the next pointer of a node points to itself. The following are the ways ... Read More

6K+ 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 understand how to get a key from a HashMap using the value. Following are the ways to get a key from a HashMap using the value: Using For Loop Using Stream API Using For Loop We can iterate through the entries of the HashMap using a for loop and check if the value matches the one we are looking for. If it does, we return the corresponding ... Read More

3K+ Views
ArrayList class in Java is a part of the Java Collections Framework and is used for storing a dynamically sized collection of elements. It is similar to an array, but it can grow and shrink in size according to the requirements of the program.Removing Duplicate Elements from an ArrayList In an ArrayList, we can store duplicate elements. In this article, we will see how to remove duplicate elements from an ArrayList in Java. The following are the methods we will use to remove duplicate elements from an ArrayList: Using removeIf() Method ... Read More

892 Views
HashMap is a part of the Java Collections Framework, and it is used for storing key-value pairs. In this article, we will see how to update the value of a HashMap using a key. We will use following methods to update the value of a HashMap: Using put() Method Using compute() Method Using replace() Method Using put() Method The put() method is used to add a key-value pair to the HashMap. If the key already exists, it will update the value that is stored with that ... Read More

2K+ Views
A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. In this example, we will see how to iterate over a Set in Java using the following methods: Using forEach() Method Using Stream API Using forEach() Method The forEach() method from the Set is used for iterating over each element of the set. We can use this method to perform an action for each element in ... Read More

464 Views
In this article, we will understand how to iterate over a HashMap. Java HashMap is a hash table based implementation of Java's Map interface. It is a collection of key-value pairs.Below is a demonstration of the same −Suppose our input is −Input Hashmap: {Java=Enterprise, JavaScript=Frontend, Mysql=Backend, Python=ML/AI}The desired output would be −The keys of the Hashmap are: Java, JavaScript, Mysql, Python, The Values of the Hashmap are: Enterprise, Frontend, Backend, ML/AI, AlgorithmStep 1 - START Step 2 - Declare namely Step 3 - Define the values. Step 4 - Create a hashmap of strings and initialize elements in it using ... Read More

414 Views
In this article, we will understand how to convert the ArrayList into a string and vice versa. The ArrayList class is a resizable array, which can be found in the java. util package. The difference between a built-in array and an ArrayList in Java is that the size of an array cannot be modified. ArrayList definitionAn ArrayList in Java is a resizable array found in the java.util package, which allows for dynamic modifications in size as elements are added or removed. It supports ... Read More