Articles on Trending Technologies

Technical articles with clear explanations and examples

How to use POSIX semaphores in C language

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 11-Jun-2025 3K+ Views

The POSIX stands for Portable Operating System which was developed by IEEE (Institute of Electrical and Electronics Engineers). This is UNIX based operating system that is used for both system calls and library functions. The semaphores are used in the process of multithreading and synchronization. For eg. file sharing and memory management. It can be named or unnamed. Multithreading is the process of executing multiple tasks in the same instance of time while synchronization is used to control the thread to work in a sequential manner. It is important for data security. Using Semaphores in C language To use ...

Read More

How to define control flow statements in JShell in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 11-Jun-2025 442 Views

In this article, we will learn about the control flow statements in JShell in Java. JShell is a new interactive command-line tool introduced in Java 9. This tool can also be called REPL (Read-Eval-Print-Loop) because it takes input, evaluates it, and returns output to the user via the command line.  JShell Control Flow Statements Control flow statements are used to control the execution path of the code and are a fundamental part of the Java programming language. We can execute multiple-line control flow statements using JShell in the same way as Java. It recognizes multiple-line statements are prompts with the ...

Read More

How to handle an exception in JShell in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 11-Jun-2025 536 Views

In this article, we will learn to handle an exception in JShell in Java 9. We will learn about the JShell, exceptions in Java, JShell exceptions, their handling, and Types of exceptions in JShell with examples. What is JShell? JShell is a new command-line interactive REPL (Read-Evaluate-Print-Loop) tool introduced in Java 9 to evaluate declarations, statements, and expressions written in Java. This tool also allows us to execute Java code snippets and get immediate results. C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> JShell provides a fast and friendly environment that ...

Read More

What is the purpose of using Optional.ifPresentOrElse() method in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 11-Jun-2025 3K+ Views

In this article, we will learn about the purpose of using the Optional.ifPresentOrElse() method in Java 9.  The Optional Class The Optional class was introduced in Java 8. Many Java developers face null pointer exceptions to avoid this, we need to put null checks we need to put if, to check if a method is null we can put it in the if statement; otherwise, we have to put it in the else statement. And to check this, we need to put this at multiple points to avoid this situation, We use the Optional class. It avoids the null pointer ...

Read More

How to use the PI constant in C++?

Aman Kumar
Aman Kumar
Updated on 10-Jun-2025 22K+ Views

The Pi is a special mathematical value, approximately 3.14159, that is often used in calculations related to circles and geometry. In C++, we need to understand how to access and use this constant in our programs. In this article, we will show how to use the PI constant in a C++ program. The PI constant is available in the cmath header file. We will explain how to use PI to calculate values like the area or circumference of a circle. How to Use Pi in C++ There are multiple ways to use the Pi constant in C++. ...

Read More

How to import external libraries in JShell in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 10-Jun-2025 2K+ Views

In this article, we will learn to import external libraries in JShell in Java 9. JShell is an interactive tool to learn the Java language and prototype Java code. This tool works on the principle of REPL (Read-Evaluate-Print-Loop). Default Imports in JShell By default, JShell automatically imports a few useful Java packages when the JShell session is started. We can type the command /imports to get a list of all these imports. jshell> /imports | import java.io.* | import java.math.* | import java.net.* | import java.nio.file.* | import java.util.* | import java.util.concurrent.* | import java.util.function.* | import java.util.prefs.* | import ...

Read More

What are new methods have added to the Arrays class in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 10-Jun-2025 335 Views

In this article, we will learn about the new methods that have been added to the Arrays class in Java 9. First, we will learn about arrays, and then the new methods added to the equals(), compare(), and mismatch() methods with examples. Arrays Java provides a data structure called the Array, and they are used to store multiple values of the same datatype in a single variable. The Arrays class can contain various methods for manipulating arrays and also contains static factory methods that allow arrays to view as a list. Creating an instance of an Array with a variable ...

Read More

What are the useful commands in JShell in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 10-Jun-2025 642 Views

In this article, we will learn about useful commands in JShell. Java 9 has introduced a new interactive tool called JShell. This tool can be used to execute, test user-friendly and easy way of Java classes, interfaces, enums, objects, statements and etc.  Different Useful Commands in JShell Below are some of the important commands in JShell: /open /var /types /methods /list /help /open To execute a script after JShell has started, we will use ...

Read More

How to define expressions, variables, and methods in JShell in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 10-Jun-2025 1K+ Views

JShell is a Read-Evaluate-Print Loop (REPL) that evaluates declarations, statements, and expressions as we have entered and immediately shows the results. This tool is run from the command prompt. Below, we can define expressions, variables, and methods in JShell. Expression The combination of variables, operators, and methods is known as an Expression in Java. They perform some logic that evaluates to a single value. int a=5, b=10, c=0; c=a+b; Here, "a+b" is an expression that evaluates the value of c as 15. Expression in JShell We can type any valid Java expression in JShell. The expression ...

Read More

What is the use of the Cleaner class in Java 9?

Alshifa Hasnain
Alshifa Hasnain
Updated on 10-Jun-2025 1K+ Views

In this article, we will learn about the use of the Cleaner class in Java 9. Below, we will first tell the basic usage and then we will know how we can use the Cleaner method practically. Garbage Collector An Object that has been created during the program execution is automatically removed by the Garbage Collector (GC). When an object not referenced by any thread and when JVM determines that this object can't be accessed, then it can be eligible for garbage collection. The finalize() method The Object class has a finalize() method, which is automatically called by GC before it attempts to remove the ...

Read More
Showing 30591–30600 of 61,297 articles
Advertisements