Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2756 of 3366
130 Views
The build() method of the DoubleStream.Builder class builds the stream. It transitions this builder to the built state.The syntax is as followsDoubleStream build()To use the DoubleStream.Builder class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream.Builder build() method in Java:Example Live Demoimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream.Builder builder = DoubleStream.builder(); builder.add(34.5); builder.add(87.1); builder.add(35.6); builder.add(66.1); builder.add(36.8); builder.add(77.4); builder.add(88.2); builder.add(68.9); builder.build().forEach(System.out::println); } }Output34.5 87.1 35.6 66.1 36.8 77.4 88.2 68.9
2K+ Views
Concatenate a string and an integer means, convert both the string and integer to a single string. In this article we will discuss all the approches to concatenate a std:string and an integer type using C/C++ program. First of all, let's understand the problem statement. We are given a standard c++ string and an integer. We have to output a single string by combining the given string and integer. For example: // Input String and Integer "Value = " 25 // Output String "Value = 25" Concatenate String and Int in C++ Here is the list ... Read More
122 Views
The add() method of the DoubleStream.Builder class in Java adds an element to the stream being built. The method returns this builder.The syntax is as followsdefault DoubleStream.Builder add(double ele)Here, ele is the element to be added to this stream.To use the DoubleStream.Builder class in Java, import the following packageimport java.util.stream.DoubleStream; Create DoubleStream.Builder: DoubleStream.Builder builder = DoubleStream.builder(); Now add some elements: builder.add(23.5); builder.add(33.1); builder.add(35.6); builder.add(53.1);The following is an example to implement DoubleStream.Builder add() method in JavaExample Live Demoimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream.Builder builder = DoubleStream.builder(); builder.add(23.5); ... Read More
713 Views
Reversing a string means, moving first character to last, second character to second last and so on. In this article we will discuss how to reverse a string in place using C/C++ program. In the "in place" string reversing, we are not allowed take extra memory to store the string while running program. First of all, let's understand our problem statement:We are given a character string as input and we need to find and output the reverse string of the given string. For example: // Input : a character string "This is a string" //Output : Reverse of ... Read More
231 Views
The take() method of the ArrayBlockingQueue class fetch and removes the head of this queue, waiting if necessary until an element becomes available.The syntax is as followspublic E take() throws InterruptedExceptionTo work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to implement take() method of Java ArrayBlockingQueue classExample Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) throws InterruptedException { ArrayBlockingQueue q = new ArrayBlockingQueue(10); q.add(200); q.add(310); q.add(400); q.add(450); q.add(500); ... Read More
935 Views
Alpha-numeric string are the strings that containing both alphabets and numbers mixed together. These are generally used in security system for generating passwords or hash keys. In this article, we will learn all the approaches for developing a C++ program to generate random alpha numeric stiring. First of all, let's understand the problem statement, We have to input a positive integer for the length of string. The program should output a string of the size containing random characters and numbers. For example, // Input Number : Length of alpha-numeric string 5 // Output String : Alpha-numeric string fd23j ... Read More
506 Views
If you have IntStream with ASCII values, then easily convert it to string using the below given example.For IntStream class, import the following packageimport java.util.stream.IntStream;Let’s say the following is our IntStreamIntStream stream = "Example".chars();Now, convert the IntStream to stringString str = stream.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();The following is an example to convert IntStream to String in JavaExampleimport java.util.stream.IntStream; class Demo { public static void main(String[] args) { IntStream stream = "Example".chars(); System.out.println("The ASCII values..."); String str = stream.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString(); System.out.println("The ... Read More
7K+ Views
In this article, we will discuss how to extract all the integers from a string using C++ program. We will explore all the possible approaches to do so. First of all, let's understand the problem statement. We have a string that contains a mix of digits and non-digits. We need to extract all the integers from the string and store them in a vector. The integers can be positive or negative. For example, // Input String string str = "ab24wj-123fow" // Output Vector vector vec = {24, -123} Approaches to Extract Integers from String ... Read More
102 Views
The sorted() method of the DoubleStream class returns a stream consisting of the elements of this stream in sorted order.The syntax is as followsDoubleStream sorted()To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create a DoubleStream and add some elements to the streamDoubleStream doubleStream = DoubleStream.of(78.9, 90.4, 27.9, 20.6, 45.3, 18.5);Now, sort the elements of the streamdoubleStream.sorted().The following is an example to implement DoubleStream sorted() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.of(78.9, 90.4, 27.9, 20.6, 45.3, 18.5); ... Read More
885 Views
In this article, we will see how to convert a string to a number and a number to string using modern C++ techniques. Understanding Strings and Numbers In C++, strings and numbers are two different data types. A string is a sequence of characters enclosed in double quotes, and a number can be any numerical value such as integer, float, double, etc. Strings are used to represent text data and numbers are used for mathematical calculations. Let's see an example of defining a string and number. // Define a string string str = "Hello World"; // Define ... Read More