Java Program to convert int array to IntStream

Krantik Chavan
Updated on 26-Jul-2024 21:47:06

2K+ Views

In Java, streams are a powerful tool for working with collections of data. They allow you to perform operations like filtering, mapping, and reducing in a simple and efficient way. One common task is converting an int array to an IntStream, so you can easily apply these operations. Problem Statement We need to convert an int array to an IntStream and find the sum of the first seven elements. This involves creating an IntStream from the array, limiting the stream to a specific number of elements, and then calculating the sum of those elements. Input arr ... Read More

Java program to implement binary search

Lakshmi Srinivas
Updated on 26-Jul-2024 21:36:20

2K+ Views

Binary search is a fast searching algorithm with run-time complexity of Ο(log n). This search algorithm works on the principle of divide and conquer. For this algorithm to work properly, the data collection should be in the sorted form. The binary search looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of the item is returned. If the middle item is greater than the item, then the item is searched in the sub-array to the left of the middle item. Otherwise, the item is searched for in the sub-array to the ... Read More

Near Field Communication

Satadru Jati
Updated on 26-Jul-2024 15:05:47

186 Views

Introduction to Near Field Communication (NFC) Near Field Communication (NFC) may be a short-range remote communication technology that permits two electronic gadgets to set up communication when they are set in the near vicinity, ordinarily inside some centimeters. NFC is an expansion of Radio Recurrence Distinguishing Proof (RFID) innovation and works at a recurrence of 13.56 MHz. NFC innovation empowers contactless communication and information trade between gadgets, making it helpful and proficient for different applications. Working of NFC The essential rule behind NFC is using electromagnetic areas for information exchange. It utilizes inductive coupling, where the NFC-enabled gadgets create attractive ... Read More

Difference Between Maskable and Non-Maskable Interrupt

Shirjeel Yunus
Updated on 26-Jul-2024 14:02:15

11 Views

Interrupt is an issue that is not caused by the CPU but is done by a component. Interrupts may occur suddenly and CPU has to take immediate action to resolve the issue. Interrupts are of many types and in this article, we will discuss the difference between Maskable and Non-Maskable Interrupts. What is Maskable Interrupt? Maskable interrupt is a kind of interrupt which can be ignored or disabled by instructions given by the CPU. The ignoring or disabling of this interrupt allows the system to give priority to certain tasks. The sources of interrupts are also disabled so that critical ... Read More

Difference Between Membrane Keyboard and Mechanical Keyboard

Shirjeel Yunus
Updated on 26-Jul-2024 13:59:40

10 Views

A keyboard is an input device which is used in computers and typewriters to type different types of alphabets, numerals, and symbols. In the case of computers, the characters typed through the keyboard are visible on the screen. Previously, keyboards were used only for typing but now games can also be played. Keyboards are of many types and in this article, we will discuss the difference between mechanical and membrane keyboards. What is a Membrane Keyboard? A membrane keyboard consists of three layers of membrane. The location of each key is different on the three-layered membrane. The membrane is sensitive ... Read More

Difference between Hard Real Time and Soft Real Time System

Shirjeel Yunus
Updated on 26-Jul-2024 13:55:21

13 Views

Real time is a system in which a deadline is given and the work has to be completed within the time. If this task is not accomplished within the given time, then there can be a huge loss. There is an operating system called RTOS which can be expanded to Real Time Operating System. The aim of designing this operating system is to manage the time constraints to complete a task or a project. Real time systems can be divided into hard real time systems and soft real time systems. In this article, we will discuss the difference between a ... Read More

How to Automatically Resolve Git Merge Conflicts in Favor of Any Side?

Dm. Mehedi Hasan Abid
Updated on 25-Jul-2024 19:49:38

124 Views

As a developer, you probably love coding but dread the inevitable merge conflicts that come with Git. These conflicts can disrupt your flow and waste precious time. Fortunately, there's a way to automate the resolution process, ensuring you can keep working smoothly. In this article, I'll show you how to set up automatic conflict resolution in Git, favoring either your changes or those from another branch. My First Encounter with Merge Conflicts I remember my first major merge conflict like it was yesterday. I had just finished a big feature and was excited to merge my branch. Instead of celebrating, ... Read More

Java program to display previous month from GregorianCalendar

Samual Sam
Updated on 25-Jul-2024 19:36:40

2K+ Views

The GregorianCalendar class in Java allows us to manipulate dates and times easily. In this example, we will create a GregorianCalendar object and use it to display the current date and the date of the previous month. Problem Statement Write a Java program and create a GregorianCalendar object, display the current date, and then modify this date to show the date of the previous month. Output Current date: Mon Nov 19 18:07:03 UTC 2018 Input Modified date (Previous Month): Fri Oct 19 18:07:03 UTC 2018 Steps to display previous month from GregorianCalendar Below are the steps to display previous ... Read More

Java program to convert integer to octal

Samual Sam
Updated on 25-Jul-2024 19:35:06

2K+ Views

In Java, converting integers to different numeral systems can be easily achieved using built-in methods. The Integer.toOctalString(int) method allows you to convert an integer to its octal string representation. This is particularly useful in applications that require data representation in octal format. To convert integer to octal in Java, use the Integer.toOctalString() method. Problem Statement Given a set of integer values, we need to convert each integer to its octal string representation using the Integer.toOctalString(int) method. Input int val = 768; Output Octal String = 1400 Step to convert the integer to octal Below are the steps to convert integer ... Read More

Java program to find maximum odd number in array using stream and filter

Shiva Keerthi
Updated on 25-Jul-2024 19:32:19

1K+ Views

In this section, we are going to write a Java program to find maximum odd number in an Array using Stream and Filter. Odd numbers are the numbers which cannot be divided by 2 or these numbers give remainder as 1 when they are divided by 2. In other terms which can be written in the form of 2n+1. We will find the maximum odd number in the array. Problem Statement Write a program in Java to find maximum odd number in array using stream and filter − Input array = {1, 7, 2, 3, 9, ... Read More

1 2 3 4 5 ... 10874 Next
Advertisements