
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

196 Views
There are many interesting facts with respect to increment and decrement operators in Java. We will discuss a few of them with examples −The increment and decrement operators can’t be used with the ‘final’ variables. This is due to the fact that variables associated with ‘final’ keyword can’t be changed −Example Live Demopublic class Demo{ public static void main(String[] args){ final int my_val = 34; int my_val_2 = ++my_val; System.out.println("The value is :"); System.out.println(my_val_2); } }Output/Demo.java:6: error: cannot assign a value to final variable my_val int my_val_2 ... Read More

187 Views
There are many facts with respect to array assignment, and we will discuss a few of them with working examples here −While creating array object type, the element that would be present inside the array can be declared as type objects or as child class’s object.Example Live Demopublic class Demo{ public static void main(String[] args){ Number[] my_val = new Number[3]; my_val[0] = new Integer(91); my_val[1] = new Double(65.963); my_val[2] = new Double(45.7965); System.out.println(my_val[0]); System.out.println(my_val[1]); System.out.println(my_val[2]); } }Output91 65.963 ... Read More

376 Views
Java compiler doesn’t allow abandoning an uninitialized local variable. When a local variable is initialized inside a conditional block, there are 3 possibilities that could potentially occur −Code compiles successfully if values are provided in the conditional block and the given condition is true.Code gives a compilation error if variables are provided (instead of values) in the conditional block and the condition is true.Code gives compilation error if the condition that needs to be checked is false.If the local variable is initialized to a default value outside of the conditional block in the code, it won’t give any error and ... Read More

431 Views
The HashSet use Hashing to manipulate data. Let us see an example − Example import java.util.*; public class Demo{ private final String f_str, l_str; public Demo(String f_str, String l_str){ this.f_str = f_str; this.l_str = l_str; } public boolean equals(Object o){ if (o instanceof Demo) return true; Demo n = (Demo)o; return n.f_str.equals(f_str) && n.l_str.equals(l_str); } public static void main(String[] args){ ... Read More

2K+ Views
Following is the code to implement Checksum using Java −Example Live Demoimport java.util.*; public class Demo{ public static void main(String args[]){ Scanner my_scan = new Scanner(System.in); System.out.println("Enter the input string "); String my_in = my_scan.next(); int my_checksum = generate_checksum(my_in); System.out.println("The checksum that has been generated is " + Integer.toHexString(my_checksum)); System.out.println("Enter the data that needs to be sent to the receiver "); my_in = my_scan.next(); System.out.println("Enter the checksum that needs to be sent to the receiver "); ... Read More

6K+ Views
We can convert a hex string to byte array in Java by first converting the hexadecimal number to integer value using the parseInt() method of the Integer class in java. This will return an integer value which will be the decimal conversion of hexadecimal value. We will then use the toByteArray() method of BigInteger class that will return a byte array.Example Live Demoimport java.math.BigInteger; public class Demo { public static void main(String args[]) { String str = "1D08A"; int it = Integer.parseInt(str, 16); System.out.println("Hexadecimal String " + str); ... Read More

198 Views
In this tutorial, we will be discussing a program to find maximum size rectangle binary sub-matrix with all 1s.For this we will be provided with 2D matrix containing zeroes and ones. Our task is to find the largest 2D matrix subset containing only ones.Example Live Demo#include using namespace std; #define R 4 #define C 4 //finding the maximum area int maxHist(int row[]) { stack result; int top_val; int max_area = 0; int area = 0; int i = 0; while (i < C) { if (result.empty() || row[result.top()]

190 Views
In this tutorial, we will be discussing a program to find maximum size of sub-array that satisfies the given condition.For this we will be provided with an array of integers. Our task is to find the maximum length subset of that array satisfying either of arr[k] > arr[k + 1] when k is odd and arr[k] < arr[k + 1] when k is even, arr[k] > arr[k + 1] when k is even and arr[k] < arr[k + 1] when k is odd.Example Live Demo#include using namespace std; //comparing values of a and b int cmp(int a, int b) { ... Read More

191 Views
In this problem, we are given an array arr[] of integers. Our task is to create a program to calculate the Maximum set bit sum in array without considering adjacent elements in C++.Problem description − Here, we have an array arr[]. We have to find the number of set bits for each number. Then, we will find the maximum set bit sum in adjacent elements of the array. i.e. maximum sum for a[i] + a[i+2] ….Let’s take an example to understand the problem, Inputarr[] = {1, 4, 6, 7}Output4ExplanationArray with the element’s in binary formarr[] = {01, 100, 101, 111} ... Read More

323 Views
In this problem, we are given a 2-D array arr[] consisting of boolean values (i.e 0’s and 1’s) and an integer K. Our task is to create a program to find the Maximum score after flipping a Binary Matrix atmost K times in C++.Problem Description − Here, for the 2-D array, and the k moves, we need to find the number that is created by the elements of the array. In each move, we will take a row or column and flip all the elements of the row or column. The choice will be done to keep in mind that ... Read More