
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

285 Views
In C++11, the lambda was introduced. Lambdas are basically a part of, that can be nested inside other function call statements. By combining lambda expressions with the auto keyword, they can be used later.In C++14, these lambda expressions are improved. Here we can get the generalized or generic lambda. For example, if we want to create a lambda, that can add integers, add numbers, also concatenate strings, then we have to use this generalized lambda.Syntax of the lambda expression is looking like this −[](auto x, auto y) { return x + y; }Let us see one example to get the ... Read More

1K+ Views
Let us first create a Stream:Stream stream = Stream.of("UK", "US", "India", "Australia", "Armenia", "Canada", "Poland");Now convert Stream to TreeSet:Set set = stream.collect(Collectors.toCollection(TreeSet::new));The following is an example to convert String to TreeSet in Java:Exampleimport java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { Stream stream = Stream.of("UK", "US", "India", "Australia", "Armenia", "Canada", "Poland"); Set set = stream.collect(Collectors.toCollection(TreeSet::new)); set.forEach(val -> System.out.println(val)); } }OutputArmenia Australia Canada India Poland UK USRead More

12K+ Views
In C we have seen different format specifiers. Here we will see another format specifier called %p. This is used to print the pointer type data. Let us see the example to get a better idea.Example#include main() { int x = 50; int *ptr = &x; printf("The address is: %p, the value is %d", ptr, *ptr); }OutputThe address is: 000000000022FE44, the value is 50

582 Views
Let us create string Stream:Stream stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");Convert the above string stream and join them with Collectors:final String str = stream.collect(Collectors.joining(" "));The following is an example to convert string Stream to join them:Exampleimport java.util.stream.Collectors; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { Stream stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming"); final String str = stream.collect(Collectors.joining(" ")); System.out.println("Join result..."+str); } }OutputJoin result... Bing Bang Theory Vampire Diaries Game of Thrones HomecomingRead More

2K+ Views
In C++11, we can get the random library to generate random numbers. Here we have used random_device once to seed the random number generator object called mt. This random_device is slower than the mt19937, but we do not need to seed it. It requests for random data to the operating system.Example #include #include using namespace std; int main() { random_device rd; mt19937 mt(rd()); uniform_real_distribution dist(20.0, 22.0); //range is 20 to 22 for (int i=0; i> dist(mt) >> endl; }Output21.5311 21.7195 21.0961 21.9679 21.197 21.2989 20.6333 20.441 20.7124 20.2654 21.1877 20.4824 20.0575 20.9432 21.222 21.162 21.1029 20.2253 21.5669 20.3357

361 Views
In this article, we will learn how to change a Java Stream into a typed array in Java. By using the toArray() method with a constructor reference, we can ensure that the array has the right type. Problem StatementGiven a Stream of strings, write a Java program to convert it into a typed array and display the elements.Input Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming")Output Array...Bing Bang TheoryVampire DiariesGame of ThronesHomecoming Steps to convert the stream to a typed array The following are the steps to covert the stream to a typed array − ... Read More

374 Views
The C/C++ library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc. Following is the declaration for free() function.void free(void *ptr)This function takes a pointer ptr. This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.Example#include #include #include using namespace std; int main () { char *str; /* Initial memory allocation */ str = (char *) malloc(15); strcpy(str, "tutorialspoint"); cout

37K+ Views
In C and C++, every character like 'A', 'b', '3', or '@' is stored as a number called its ASCII value. For example, 'A' is 65, and 'a' is 97. Given an integer like 97, we can convert it to its corresponding ASCII character which is 'a'. In this article, we will learn how to write a C and C++ program to convert an integer into its ASCII character. For example, we're given any integer from 0 to 127 (because the ASCII table contains 128 characters), and we need to convert it into its corresponding ASCII character: Input: 65 ... Read More

241 Views
Here we will see how to pass reference of some variable in C++. Sometimes we call it as “Call by Reference”.The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument.To pass the value by reference, argument reference is passed to the functions just like any other value. So accordingly you need to declare the function parameters as reference types as in ... Read More

444 Views
To right align the text in a JComboBox, use the following:ComponentOrientation.RIGHT_TO_LEFTThe following is an example to right align the text in a ComboBox:Exampleimport java.awt.Component; import java.awt.ComponentOrientation; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JList; public class SwingDemo extends JFrame { public SwingDemo() { JComboBox combo = new JComboBox(); combo.setRenderer(new MyListCellRenderer()); combo.addItem("One"); combo.addItem("Two"); combo.addItem("Three"); combo.addItem("Four"); combo.addItem("Five"); getContentPane().add(combo, "North"); setSize(600, 400); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { ... Read More