
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
Found 33676 Articles for Programming

722 Views
The mapToLong() function in IntStream class returns a LongStream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows.LongStream mapToLong(IntToLongFunction mapper)Here, the parameter mapper is a stateless function to apply to each element.Create an IntStream with some elements in the Stream.IntStream intStream = IntStream.of(50, 100, 150, 200);Now create a LongStream and use the mapToLong() with a condition.LongStream longStream = intStream.mapToLong(num → (long)num);The following is an example to implement IntStream mapToLong() method in Java.Exampleimport java.util.*; import java.util.stream.IntStream; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { ... Read More

436 Views
A multimap is an associative container that stores elements in a key-value pair format, where multiple values can share the same key. In this article, we will learn how to use a multimap from the Standard Template Library (STL) in C++. What is Multimap? Multimap is a sorted associative container that stores data in key-value pairs, where keys can occur multiple times. Keys are stored in sorted order, and you can insert, access, and remove elements based on the key. For example, in a multimap we can store student names with their scores even if some students have ... Read More

160 Views
The iterator() method of the LongStream class in Java returns an iterator for the elements of this stream.The syntax is as follows.PrimitiveIterator.OfLong iterator()Here, PrimitiveIterator is an Iterator specialized for long values.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;The following is an example to implement LongStream iterator() method in Java.Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(15000L, 17000L, 25000L); PrimitiveIterator.OfLong i = longStream.iterator(); while (i.hasNext()) { System.out.println(i.nextLong()); } ... Read More

4K+ Views
A map is an associative container that stores elements in a key-value pair format. Each element has a unique key and a corresponding mapped value. No two mapped values can have the same key. In this article, we will learn how to use a map from the Standard Template Library (STL) in C++. What is Map? Map is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted automatically, and each key is associated with a value. You can insert, access, and remove elements based on the key. For example, we can store ... Read More

114 Views
You can easily create Octet Tuple in Java using with() method. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package.import org.javatuples.Octet;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 JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to create Octet Tuple using with() ... Read More

399 Views
A List in C++ STL library is hardcoded implementation of a doubly linked list data structure. In this article, we will learn how to implement and use a list in C++ . What is List? List is a doubly linked container provided in the C++ STL library, in which each element points to both its previous and next elements. Meaning, in this list we can quickly traverse in both forward and backward direction using pointers just like a doubly linked list. Compared to vectors or arrays, these lists allow fast insertions and deletions from the middle of the sequence. ... Read More

513 Views
The AbstractCollection class provides an implementation of the Collection interface. This is done to minimize the effort in the implementation of this interface.For an unmodifiable collectionExtend this class and provide implementations for the iterator and size methods.For modifiable collectionAdditionally override the add() method of the class. The iterator method returns the iterator and it must implement the remove() method.The syntax is as follows.public abstract class AbstractCollection extends Object implements CollectionHere, Object is the root of the class hierarchy and Collection is a group of objects.To work with AbstractCollection class in Java, import the following package.import java.util.AbstractCollection;Let us now see an ... Read More

364 Views
The setEmptyValue() method of the StringJoiner class in Java 8 sets the sequence of characters. These characters are to be used when determining the string representation of this StringJoiner and when it is empty. That would be none of the elements have been added.The syntax is as followspublic StringJoiner setEmptyValue(CharSequence emptyVal)Here, emptyVal are the characters to return as the value of an empty StringJoinerTo work with the StringJoiner in Java 8, import the following package.import java.util.StringJoiner;The following is an example to implement StringJoiner setEmptyValue() method in Java:Example Live Demoimport java.util.StringJoiner; public class Demo { public static void main(String[] args) { ... Read More

264 Views
Forward List is a type of singly linked list available in the C++ STL (Standard Template Library). In this artcile, we will learn how to use forward_list from C++ STL library. What is Forward List? Forward list is a linear data structure which allows traversal only in one direction. It is similar to a singly linked list where each element points to the next element and moves in forward direction. It supports operations like insertion, deletion, and traversal from the beginning to end but not in reverse direction. The insertion and deletion operations are comparatively very fast in ... Read More