Get Unique Values from ArrayList in Java

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

2K+ 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, we are going to see the practical implementation of those approaches through Java example programs. Java Program to get Unique Values from ArrayList Before jumping to the solution program for the given problem, let’s discuss the following concepts of Collection Interface − HashSet It is a class of Java Collection ... Read More

Modify Element of a PriorityQueue in Java

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

695 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 comparator. The elements of PriorityQueue are not actually sorted, they are only retrieved in sorted order. This feature allows us to modify an element of PriorityQueue easily. Java Program to modify an element of a ProrityQueue Before jumping into the program, let’s familiarize ourselves with a few in-built methods of ... Read More

Difference Between SAX Parser and DOM Parser in Java

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

4K+ 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. APIs are a modern way to migrate real time information on the Web. In this article, we will discuss the difference between SAX and DOM Parser in Java. Type of XML Parser Before going further in this article, let’s briefly discuss XML and its type. XML Its full form is ... Read More

Getter and Setter in Java

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

2K+ 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 details from the outside world. Data hiding means preventing direct access of the members of class from the internal state of an object. In this article, we will explain what getter and setter methods are in Java and how they are useful in data hiding. Getter and Setter methods The ... Read More

Producer-Consumer Solution Using BlockingQueue in Java

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

2K+ 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 Producer Consumer Problem Producer and Consumer are two distinct entities or processes that use a shared queue. This queue is of a fixed size buffer. The producer generates pieces of information and stores them in the queue. The consumer consumes the given information and removes them from the queue. The ... Read More

Call C Function in Python

Prince Yadav
Updated on 20-Jul-2023 19:27:57

10K+ Views

Calling C functions in Python can greatly enhance the capabilities of your programs by incorporating functionality from C libraries. Python, known for its simplicity and versatility, offers various methods to seamlessly integrate C code, resulting in improved performance and access to low−level system APIs. This article explores the topic of calling C functions in Python, highlighting different approaches that leverage Python's strengths. One popular method is using the ctypes library, which allows direct invocation of C functions from dynamic link libraries. We will also delve into the CFFI library, which provides a high−level interface for calling C functions, and the ... Read More

Emulate N Dice Roller Program

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

318 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’ that comes under ‘java.util’ package. Java program to Emulate N Dice Roller Random Class We create an object of this class to generate pseudorandom numbers within a given range. We will customize this object and apply our own logic to select any random values from the specified dice. To retrieve ... Read More

Higher Lower Game with Python

Prince Yadav
Updated on 20-Jul-2023 19:23:55

6K+ Views

The Higher−Lower game is a classic and entertaining guessing game that challenges players to guess a randomly generated number within a specified range. By implementing this game using the Python programming language, beginners can gain valuable coding experience while creating an interactive and enjoyable gaming experience. In this article, we will explore the step−by−step process of creating a Higher−Lower game with Python, providing detailed explanations and code examples along the way. Whether you're a novice programmer looking to enhance your skills or simply seeking a fun coding project, this article will guide you through the development of a fully ... Read More

Get Request Query Parameters with Flask Using Python

Prince Yadav
Updated on 20-Jul-2023 19:20:27

4K+ Views

Flask, a high−powered web framework for Python, provides developers with an intuitive and efficient way to handle GET request query parameters. When users interact with web applications, query parameters are often sent as part of the URL, conveying additional information to the server. With Flask, extracting and utilizing these query parameters becomes a seamless process. This article will explore the world of GET request query parameters with Flask and Python. We will explore the fundamental concepts of handling GET requests and parsing query parameters. Additionally, we will demonstrate examples that showcase how to effectively extract and manipulate the data obtained ... Read More

Steps to Create a Servlet

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

2K+ 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 working with the servlet They are useful when it comes to creating dynamic web pages and processing user inputs. This article aims to discuss all the necessary steps to create a servlet in detail. Steps to create a Servlet Before moving to the steps let’s discuss briefly about servlets. How ... Read More

Advertisements