Programming Articles - Page 1726 of 3366

Difference between PermGen Space and MetaSpace.

Himanshu shriv
Updated on 09-Sep-2020 11:29:52

4K+ Views

PermGen is the memory area for storing class data like static variable, byte code and etc. By default 64 Mb is allocated for PermGen. It can be tuned by using -XXMaxPermSize.In Java 8, PermGen method area replaced with MetaSpace. They have moved permGem to the separate memory in the native OS and that is called MetaSpace. It can by default auto increases its size. In MetaSpace, classes can load and unload during the lifespan of the JVM.Sr. No.KeyPermGenMetaSpace1BasicPermGen is the memory area for storing class data like static variable, byte code and etcIn Java 8, PermGen method area replaced with ... Read More

Program to find Cullen Number in C++

Ayush Gupta
Updated on 09-Sep-2020 11:27:30

155 Views

In this tutorial, we will be discussing a program to find Cullen Number.For this we will be provided with an integer. Our task is to find the cullen number at that position using the formula −2n* n + 1Example Live Demo#include using namespace std; //finding the nth cullen number unsigned get_cullen(unsigned n){    return (1

Difference between Iterator and Spilt Iterator in Java.

Himanshu shriv
Updated on 09-Sep-2020 11:27:40

1K+ Views

Iterator and split iterator both interface are used for iterating over the collection.Split iterator is introduced in Java 8 for achieving parallelism. It can split the given set of element and can perform operation parallely using different independent threads. It can traverse the elements parallely as well as sequentially manner. There are following important methods in the splitIterator interface −trySplit - It is used for split the given set of elements into multiple pieces.tryAdvance - It is equivalent to the hasNext/ next methods available in Iterator interfacegetExactSizeIfKnown  -It is used to get the size of the given set of elements.Sr. ... Read More

Program to find covariance in C++

Ayush Gupta
Updated on 09-Sep-2020 11:25:14

728 Views

In this tutorial, we will be discussing a program to find covariance.For this we will be provided with two sets of random variables. Our task is to calculate their covariance i.e, the measure of how much those two values differ together.Example Live Demo#include using namespace std; //function to find mean float mean(float arr[], int n){    float sum = 0;    for(int i = 0; i < n; i++)    sum = sum + arr[i];    return sum / n; } //finding covariance float covariance(float arr1[], float arr2[], int n){    float sum = 0;    for(int i = 0; i ... Read More

Program to find count of numbers having odd number of divisors in given range in C++

Ayush Gupta
Updated on 09-Sep-2020 11:22:36

417 Views

In this tutorial, we will be discussing a program to find the count of numbers having odd number of divisors in a given range.For this we will be provided with the upper and lower limits of the range. Our task is to calculate and count the number of values having an odd number of divisors.Example Live Demo#include using namespace std; //counting the number of values //with odd number of divisors int OddDivCount(int a, int b){    int res = 0;    for (int i = a; i

Difference between intermediate and terminal operations in Java 8

Himanshu shriv
Updated on 09-Sep-2020 11:25:15

16K+ Views

Stream is introduced in Java 8, it is only used for processing group of data not for the storting elements.. It does not modify the actual collection, they only provide the result as per the pipelined methods.Stream api supports multiple operations and operations are divided into two parts −Intermediate Operation- These operations are used to pipeline other methods and to transform into the other streams. They don’t produce results because these operation does not invoke until the terminal operation gets executed. Below are the examples −sorted(Comparator)peek(Consumer)distinct()Terminal operations - These operations are used to produce results. They can’t be used for ... Read More

Program to find correlation coefficient in C++

Ayush Gupta
Updated on 09-Sep-2020 11:20:26

2K+ Views

In this tutorial, we will be discussing a program to find correlation coefficient.For this we will be provided with two arrays. Our task is to find the correlation coefficient denoting the strength of the relation between the given values.Example Live Demo#include using namespace std; //function returning correlation coefficient float find_coefficient(int X[], int Y[], int n){    int sum_X = 0, sum_Y = 0, sum_XY = 0;    int squareSum_X = 0, squareSum_Y = 0;    for (int i = 0; i < n; i++){       sum_X = sum_X + X[i];       sum_Y = sum_Y + Y[i];   ... Read More

Difference between Function and Predicate in Java 8

Himanshu shriv
Updated on 09-Sep-2020 11:22:33

8K+ Views

Function and Predicate both functional interface was introduced in Java 8 to implement functional programming in Java.Function interface is used to do the transformation.It can accepts one argument and produces a result. On the other side, Predicate can also accept only one argument but it can only return boolean value. It is used to test the condition.Sr. No.KeyFunctionPredicate1BasicIt can take 2 type parameters First one represents input type argument type and second one represents return type.It can take one type parameter which represents input type or argument type.2Return TypeIt can return any type of value.It can only return boolean value3MethodIt ... Read More

Difference between scheduledThread pool and Single Thread Executor.

Himanshu shriv
Updated on 09-Sep-2020 11:16:53

1K+ Views

Sr. No.KeyScheduled Thread PoolSingle Thread Executor1BasicCreates a thread pool that can schedule commands to run after a given delay, or to execute periodically. Tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time2QueueIt uses Delay Queue to store tasks. Schedule the task based on time delay.It uses blocking queue.3Thread LifetimeT he number of threads to keep in the pool, even if they are idleRecreate thread if killed because of the task.4.Thread Pool SizeIt always has a single thread running.The thread pool can grow from zero threads to Integer.MAX_VALUE5.Use CaseWe should used fixedthreadpool, ... Read More

Program to find compound interest in C++

Ayush Gupta
Updated on 09-Sep-2020 11:17:09

423 Views

In this tutorial, we will be discussing a program to find compound interest.Compound interest is the interest by adding the current interest to the principal sum and then calculating the interest on the updated amount.Example Live Demo#include using namespace std; int main(){    double principle = 10000, rate = 10.25, time = 5;    //calculating compound interest    double CI = principle * (pow((1 + rate / 100), time));    cout

Advertisements