How to get the parent process of the Process API in Java 9?

Alshifa Hasnain
Updated on 12-Jun-2025 17:32:47

859 Views

In this article, we will learn to get the parent process of the Process API in Java 9. First, we will know about Process API and its methods, after that we will learn about the ProcessHandle interface. Process API In Java, the Process API, we can perform any operation regarding a process. The Process class provides methods for performing input on the processes, performing output to the processes, finding child and parent processes of the currently running process, and destroying the process. The following are some of the common methods of the Process API: destroy(): ... Read More

Explain quantifiers in Java regular expressions

Alshifa Hasnain
Updated on 12-Jun-2025 17:31:35

659 Views

Quantifiers in Java are special characters that allow you to specify the number of times a character or group of characters can occur in a regular expression. The most common quantifiers are: *: One or more instances of the character or set of characters that came before it. ?: The character or set of characters before it, either zero or one instance. ... Read More

C++ Program to print the diamond shape

Farhan Muhamed
Updated on 12-Jun-2025 17:26:36

592 Views

In this article, we will learn how to print a diamond shape with 2n rows and n columns for a given size n using C++. For example, if n = 4, the diamond shape will look like this: Algorithm to Print Diamond Shape To print the diamond shape, we can follow these steps: Take an integer input n from the user. To print upper half of the diamond, use a loop that runs from i = 1 to i

C++ Program to Check if any Graph is Possible to be Constructed for a Given Degree Sequence

Farhan Muhamed
Updated on 12-Jun-2025 17:23:27

178 Views

We are given an array of integers containing the degree of each vertex in a graph. Our task is to check if it is possible to construct a graph with the given degree sequence. Example: int degrees[] = {3, 2, 2, 0} Output: Not Possible Explanation: The first vertex has degree 3, which means it must be connected to three other vertices. But the last vertex has degree 0, meaning it cannot be connected to any other vertex. Hence, it is impossible to construct a graph with this degree sequence. To implement this in C++, we can ... Read More

Minimum removals to make array sum even in C++

Ravi Ranjan
Updated on 12-Jun-2025 17:20:06

259 Views

In this article, we have an array arr[] of N integers. Our task is to write a program to find the minimum number of elements needed to be removed from the given array so that the sum of the remaining elements is even. Example The following example demonstrates the minimum number of elements we need to remove from the array for the sum to be even: Input: arr = {12, 23, 40, 53, 17} Output: 1 Input: arr = {20, 11, 13, 40, 24} Output: 0 The explanation of ... Read More

Minimum removals to make array sum odd in C++

Ravi Ranjan
Updated on 12-Jun-2025 17:19:43

272 Views

In this article, we have an array arr[] of N integers. Our task is to write a program to find the minimum number of elements needed to be removed from the given array so that the sum of the remaining elements is odd. Example The following example demonstrates the minimum number of elements we need to remove from the array for the sum to be odd: Input: arr = {12, 23, 40, 53, 17} Output: 0 Input: arr = {20, 11, 13, 40, 24} Output: 1 The explanation of the above example is ... Read More

Count elements smaller than or equal to x in a sorted matrix in C++

Ravi Ranjan
Updated on 12-Jun-2025 17:19:15

254 Views

In this article, we are given a matrix of size m x n and an integer variable X. The row elements and the first column of the matrix are sorted in increasing order. Our task is to count the number of elements that are equal to or less than the given X value. Counting Elements Smaller Than X in a Sorted MatrixHere are the approaches for counting elements smaller than X in a sorted matrix: Using Linear Search Using Staircase Search Using Linear ... Read More

When to use the readAllBytes() method of InputStream in Java 9?

Alshifa Hasnain
Updated on 12-Jun-2025 16:00:14

10K+ Views

In this article, we will learn to use the readAllBytes() method of InputStream in Java 9. We will get to know the readAllBytes() method with its syntax, then we will learn about the InputStream Class with its methods, and lastly, we will learn the use of readAllBytes() with an example What is the readAllBytes() Method? In Java 9, the readAllBytes() method reads all bytes from an InputStream object at once and blocks until all remaining bytes have been read and the end of the stream is detected, or an exception is thrown. It returns a byte array containing the ... Read More

How to get dates using LocalDate.datesUntil() method in Java 9?

Alshifa Hasnain
Updated on 12-Jun-2025 15:58:17

2K+ Views

In this article, we will learn to get dates using the LocalDate.datesUntil() method in Java 9. We will learn about date ranges, skip or limit results and by using the Period class we will apply the custom steps. What is a LocalDate? LocalDate is a part of java.time package and is an immutable, date-time object, which often represents a date in the "year-month-day" format. For example, the value of "2nd May 2025" could be stored in a LocalDate. The following are the maximum and minimum values of the LocalDate: MAX: The maximum supported LocalDate, '+999999999-12-31'. ... Read More

How to get all children of a process using Process API in Java 9?

Alshifa Hasnain
Updated on 12-Jun-2025 15:53:54

1K+ Views

In this article, we will learn to get all children of a process using Process API in Java 9. First, we will learn about Process API and its methods, ProcessHandle interface and after that we will use the children method of the ProcessHandle interface. Process API In Java, the Process API, we can perform any operation regarding a process. The Process class provides methods for performing input on the processes, performing output to the processes, waiting for the process to complete, finding child and parent processes of the currently running process, getting any information about a process, and destroying the process. The ... Read More

Advertisements