Found 33676 Articles for Programming

Switch case statement in C

Nitya Raut
Updated on 30-Jul-2019 22:30:25

1K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.The syntax for a switch statement in C programming language is as follows −switch(expression) {    case constant-expression :       statement(s);       break; /* optional */    case constant-expression :       statement(s);       break; /* optional */       /* you can have any number of case statements */    default : /* Optional */       ... Read More

IntStream summaryStatistics() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

606 Views

The summaryStatistics() method in the IntStream class is used to return summary data about the elements of this stream. The syntax is as follows:IntSummaryStatistics summaryStatistics()Create an IntStream and add some elements:IntStream intStream = IntStream.of(30, 60, 90);Now, get the summary data about the above elements:IntSummaryStatistics details = intStream.summaryStatistics();The following is an example to implement IntStream summaryStatistics() method in Java:Example Live Demoimport java.util.stream.IntStream; import java.util.IntSummaryStatistics; public class Demo {    public static void main(String[] args) {       IntStream intStream = IntStream.of(30, 60, 90);       IntSummaryStatistics details = intStream.summaryStatistics();       System.out.println("Details = "+details);    } }OutputDetails = IntSummaryStatistics{count=3, ... Read More

How to generate Infinite Stream of Integers in Java using IntStream.iterate()

Nancy Den
Updated on 30-Jul-2019 22:30:25

219 Views

To generate an infinite stream of integer, use the IntStream.iterate(). The method is used to iterator an IntStream.Import the following package for the IntStream class in Java:import java.util.stream.IntStream;The following is an example displaying how to generate Infinite Stream of Integers with IntStream.iterate() in Java:Exampleimport java.util.stream.IntStream; public class Main {    public static void main(String[] args) {       IntStream.iterate(0, k -> k + 2).forEach(System.out::println);    } }Here is the output that displays integers infinitely:0 2 4 6 8 10 12 . . .

The build() method in Java Stream.Builder

Nancy Den
Updated on 30-Jul-2019 22:30:25

5K+ Views

The build() method in Stream.Builder class is used to build the stream. It returns the built stream.The syntax is as follows:Streaml build()Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;Declare a Stream.Builder:Stream.Builder builder = Stream.builder();Add some elements in the stream:builder.add("One"); builder.add("Two"); builder.add("Three");Now, use the build() method:Stream str = builder.build();The following is an example displaying how to implement build() method of Stream.Builder in Java:Example Live Demoimport java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream.Builder builder = Stream.builder();       builder.add("One");       builder.add("Two");       builder.add("Three");       ... Read More

DoubleStream count() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

168 Views

The count() method of the DoubleStream class returns the count of the elements in the stream.The syntax is as follows:long count()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9);Now, get the count of elements in the DoubleStream:long res = doubleStream.count();The following is an example to implement DoubleStream count() method in Java:Example Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9);       long res = doubleStream.count();       ... Read More

C++ Program to Implement AVL Tree

Aman Kumar
Updated on 30-May-2025 18:42:56

23K+ Views

In this article, we will demonstrate how to implement an AVL tree. An AVL tree is a self-balancing binary search tree in which the height difference between the left and right subtrees (balance factor) of any node cannot exceed one. AVL TREE Following are the points of an AVL tree − Tree rotation is a way to change the structure of an AVL tree without changing the order of the elements. It helps keep the tree balanced by moving one node up and one node down. Tree rotations are mainly used ... Read More

DoubleStream min() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

128 Views

The min() method of the DoubleStream class returns an OptionalDouble describing the minimum element of this stream, or an empty OptionalDouble if this stream is empty.The syntax is as follows:OptionalDoublemin()Here, OptionalDouble is a container object which may or may not contain a double valueTo use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create a DoubleStream and add elements to the stream:DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Get the maximum element from the DoubleStream:OptionalDouble res = doubleStream.max();The following is an example to implement DoubleStream min() method in Java:Example Live Demoimport java.util.OptionalDouble; import java.util.stream.DoubleStream; public class Demo {    public ... Read More

Difference between ++*p, *p++ and *++p in c++

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

In this section we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has priority higher than both prefix ++ and dereference operator ‘*’.When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)Example Code Live Demo#include using namespace std; int main() { char arr[] = "Hello World"; char *ptr = arr; ++*ptr; cout

Implementing own Hash Table with Open Addressing Linear Probing in C++

Samual Sam
Updated on 30-Jul-2019 22:30:25

1K+ Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.Linear probing is a collision resolving technique in Open Addressed Hash tables. In this method, each cell of a hash table stores a single key–value pair. If a collision is occurred by mapping a new key to a cell of the hash table that is already occupied by another key. This method searches the table for the following closest free location and inserts the ... Read More

LongStream min() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

141 Views

The min() method of the LongStream class in Java returns an OptionalLong describing the minimum element of this stream, or an empty optional if this stream is empty.The syntax is as follows:OptionalLong min()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream min() method in Java. The isPresent() method of the OptionalLong class returns true if the value is present:Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {     ... Read More

Advertisements