
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

9K+ Views
The datatype size_t is unsigned integral type. It represents the size of any object in bytes and returned by sizeof operator. It is used for array indexing and counting. It can never be negative. The return type of strcspn, strlen functions is size_t.Here is the syntax of size_t in C language, const size_t var_name;Here, var_name − This the name of variable.Here is an example of size_t in C language, Example Live Demo#include #include #include int main(void) { const size_t x = 150; int a[x]; for (size_t i = 0;i < x; ++i) a[i] = ... Read More

749 Views
There are so many C++ code formatter or beautifier tools which beautifies your code or format with proper indentation. The C++ code formatter/ beautifier are listed as follows − C++ Code Formatter/Beautifier Description Astyle This is a source code formatter. It can be used for C++, java and other languages. It’s latest version is 2.03 and it released in April 2013. Clang-Format It is a command line tool along with clang compiler. It is open- source tool and programmed in C++, python. The latest version is 3.3. Universal Indent GUI It ... Read More

1K+ Views
Increment operators are used to increase the value by one while decrement works opposite. Decrement operator decrease the value by one.Pre-increment (++i) − Before assigning the value to a variable, the value is incremented by one.Post-increment (i++) − After assigning the value to a variable, the value is incremented.Here is the syntax of i++ and ++i in C++ language,++variable_name; // Pre-increment variable_name++; // Post-incrementHere,variable_name −Name of the variable given by user.Here is an example of pre and post increment in C++ language,Example Live Demo#include using namespace std; int main() { int i = 5; cout

4K+ Views
A stack and a heap are used for memory allocation in Java. However, the stack is used for primitive data types, temporary variables, object addresses etc. The heap is used for storing objects in memory.Stacks and heaps in Java are explained in more detail as follows −Stack in JavaStacks are used to store temporary variables, primitive data types etc. A block in the stack exists for a variable only as long as the variable exists. After that, the block data is erased and it can be used for storing another variable.

699 Views
This example shows how to search the minimum and maximum element in an array by using Collection.max() and Collection.min() methods of Collection class.Example Live Demoimport java.util.Arrays; import java.util.Collections; public class Main { public static void main(String[] args) { Integer[] numbers = { 8, 2, 7, 1, 4, 9, 5}; int min = (int) Collections.min(Arrays.asList(numbers)); int max = (int) Collections.max(Arrays.asList(numbers)); System.out.println("Min number: " + min); System.out.println("Max number: " + max); } }OutputThe above code sample will produce the following result.Min number: 1 Max number: 9Another ... Read More

2K+ Views
In order to get frequency of each in a string in Java we will take help of hash map collection of Java.First convert string to a character array so that it become easy to access each character of string.Now compare for each character that whether it is present in hash map or not in case it is not present than simply add it to hash map as key and assign one as its value.And if character is present than find its value which is count of occurrence of this character in the string (initial we put as 1 when it ... Read More

768 Views
Fibonacci numbers of Fibonacci series grows exponentially and can be very large for large numbers like 500 or 1000. To handle such number, long data type is not sufficient. BigInteger can handle large number easily. BigInteger is useful in scenarios where calculations results in data which is out of limit for available primitive data types. See the example below of getting Fibonacci number of 100 and 1000.Example Live Demoimport java.math.BigInteger; public class Tester { public static void main(String args[]) { System.out.println("Fibonacci of 100: "); System.out.println(fibonacci(100)); System.out.println("Fibonacci of 1000: "); ... Read More

529 Views
As we know that Java needs main() method to be static in the public class to make it executable. The prime reason for this requirement is to make JVM enable to call the main() method without creating an object. That simply means that JVM does not create the object of the Main class which contains the main() method. To justify the same, we can make the Main class containing the main method as abstract and program still runs.Following example showcases the same. Here we have made the main class abstract.Exampleabstract public class Tester { public static void main(String args[]) ... Read More

735 Views
x++ automatically handles the type casting where as x= x + 1 needs typecasting in case of x is not an int variable. See the example below.Example Live Demopublic class Tester { public static void main(String args[]) { byte b = 2; //Type casting is required //as 1 is int and b is byte variable b = (byte) (b + 1); System.out.println(b); byte b1 = 2; //Implcit type casting by the compiler b1++; System.out.println(b1); } }Output3 3

717 Views
HashMap, TreeMap and LinkedHashMap all implements java.util.Map interface and following are their characteristics.HashMapHashMap has complexity of O(1) for insertion and lookup.HashMap allows one null key and multiple null values.HashMap does not maintain any order.TreeMapTreeMap has complexity of O(logN) for insertion and lookup.TreeMap does not allow null key but allow multiple null values.TreeMap maintains order. It stores keys in sorted and ascending order.LinkedHashMapLinkedHashMap has complexity of O(1) for insertion and lookup.LinkedHashMap allows one null key and multiple null values.LinkedHashMap maintains order in which key-value pairs are inserted.Example Live Demoimport java.util.HashMap; import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.Map; import java.util.TreeMap; public class Tester { ... Read More