Shriansh Kumar has Published 175 Articles

Get Unique Values from ArrayList in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:55:09

771 Views

ArrayList is a class of Java Collection Framework that implements List Interface. It is a linear structure that stores and accesses each element sequentially. It allows the storage of duplicate elements however, there are a few approaches that may help to get unique values from an ArrayList. In this article, ... Read More

How can I modify an element of a PriorityQueue in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:50:54

312 Views

Generally, the Queue follows the First in First out (FIFO) approach but a PriorityQueue follows a priority based approach while accessing elements. Each element of the queue has a priority associated with it. The elements are prioritized based on natural sorting order. However, we can provide custom orders using a ... Read More

Difference between SAX Parser and DOM Parser in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:45:54

2K+ Views

Both SAX and DOM are a type of XML parser APIs. Here, API stands for Application Programming Interface and Parser is used to read and extract content from an XML document in desired format. From this line, it is clear that SAX and DOM are used to read XML documents. ... Read More

Getter and Setter in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:35:47

874 Views

Getter and setter are two special methods in Java that allow accessing and modifying data members' values. They are mostly used in encapsulation and data hiding to protect our sensitive data from unauthorized access. In encapsulation, we group related data and behavior together in a class and hide the implementation ... Read More

Producer Consumer Solution using BlockingQueue in Java Thread

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:30:21

744 Views

Producer Consumer is the most common problem of Java concurrency and multi-threading. It arises during the synchronization that helps to manage multiple threads trying to access a shared resource. This article will help us to find Producer Consumer Solution using BlockingQueue in Java Thread. Producer Consumer Problem and BlockingQueue Understanding ... Read More

Program to Emulate N Dice Roller

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:25:03

129 Views

Suppose we have ‘N’ number of dice and we roll all of them at a time, then we need to show all the values that occurred on all dice. We have to emulate the same situation using Java programs. To solve this problem, we will use a class named ‘Random’ ... Read More

Steps to Create a Servlet

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 19:19:58

1K+ Views

Servlets are small Java modules that are used on the server side of a web connection to enhance the functionality of web server. All the methods and classes for creating a servlet are available in ‘javax.servlet’ and ‘javax.servlet.http’ packages. Hence, it is important to import them into your program before ... Read More

IntFunction Interface in Java with Examples

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 17:59:27

289 Views

In Java, the IntFunction interface is a functional interface that represents a function that accepts an integer type value as an argument and returns a result of any data type. Here, the functional interface means an interface that contains only a single abstract method and exhibits single functionality. Some examples ... Read More

Internal Working of TreeMap in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 17:44:35

417 Views

TreeMap is a class of Java Collection Framework that implements NavigableMap Interface. It stores the elements of the map in a tree structure and provides an efficient alternative to store the key-value pairs in sorted order. Internally, TreeMap uses a red-black tree, which is a self-balancing binary search tree. A ... Read More

Integer.valueOf() vs Integer.parseInt() with Examples

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 17:05:54

348 Views

In Java, both Integer.parseInt() and Integer.valueOf() methods are used for the conversion of a String into an Integer. These static methods belong to the Integer class of java.lang package and throws a NumberFormatException if the string is not a valid representation of an integer. But wait, the question arise ... Read More

Previous 1 ... 5 6 7 8 9 ... 18 Next
Advertisements