- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34472 Articles for Programming
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
168 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
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
725 Views
In this section we will see how to generate a random alphanumeric string using C++. Here we are providing lowercase letters, uppercase letters and numbers (0-9). This program takes the characters randomly, then creates the random string.Input: Here we are giving the string length Output: A random string of that length. Example “XSme6VAsvJ”AlgorithmStep 1:Define array to hold all uppercase, lowercase letters and numbers Step 2: Take length n from user Step 3: Randomly choose characters’ n times and create a string of length n Step 4: EndExample Code Live Demo#include #include #include #include using namespace std; static ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
321 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
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
5K+ Views
Here we will see how to extract all integers from strings in C++. We can put a string where numbers and no-numbers are present. We will extract all numeric values from it.To solve this problem, we will use the stringstream class in C++. We will cut the string word by word and then try to convert it into integer type data. if the conversion is done, then it is integer and print the value.Input: A string with some numbers “Hello 112 World 35 75” Output: 112 35 75AlgorithmStep 1:Take a number string Step 2: Divide it into different words Step ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
50 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
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
612 Views
In this section we will see how to convert string to number and number to string. At first we will see how to convert string to number.String to Number ConversionHere we will see how to convert a number string to integer type data. We can solve this problem by using the atoi() function. This function takes string as input and converts into integer data.The atoi() function is present in the library.Input: A number string “1234” Output: 1234AlgorithmStep 1:Take a number string Step 2: Convert it to integer using atoi() function Step 3: Print the result. Step 4: EndExample Code Live ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
852 Views
The toCollection() method of the Collectors class in Java returns a Collector that accumulates the input elements into a new Collection in encounter order.The syntax is as followsstatic Collector toCollection(Supplier collectionFactory)Here, the parameterT - Type of the input elementsC - Type of the resulting CollectionSupplier: A supplier of resultscollectionFactory - Supplier that returns a new, empty Collection of the appropriate typeTo work with Collectors class in Java, import the following packageimport java.util.stream.Collectors;The following is an example to implement toCollection() method in JavaExample Live Demoimport java.util.Collection; import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; public class Demo { public static void main(String[] ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
237 Views
Here we will see how to convert a number string to integer type data. We can solve this problem by using the atoi() function. This function takes string as input and converts into integer data.The atoi() function is present in the library.Input: A number string “1234” Output: 1234AlgorithmStep 1: Take a number string Step 2: Convert it to integer using atoi() function Step 3: Print the result. Step 4: EndExample Code Live Demo#include #include using namespace std; main() { int n; char num_string[20] = "1234"; n = atoi(num_string); cout
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
16K+ Views
In this program we will see how to convert an integer to hex string. To convert an integer into hexadecimal string we can follow mathematical steps. But in this case we have solved this problem using simple trick.In C / C++ there is a format specifier %X. It prints the value of some variable into hexadecimal form. We have used this format specifier to convert number into a string by using sprintf() function.Input: An integer number 255 Output: FFAlgorithmStep 1:Take a number from the user Step 2: Make a string after converting number using %X format specifier Step 3: Print ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
72 Views
To create Ennead Tuple, you can use the with() method or even constructor. Let us see how to create Ennead Tuple and add elements to it with Constructor.Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following packageimport org.javatuples.Ennead;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuplesSteps ... Read More