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
Programming Articles - Page 2436 of 3366
1K+ Views
In this article, we will learn how to sort an ArrayList in ascending order using Java. Sorting allows us to arrange elements in a specific order. We will use the Collections.sort() method, which simplifies sorting, whether you're dealing with integers or strings. The program will demonstrate sorting an ArrayList of numbers and names in ascending order. Problem Statement Write a Java program that sorts an ArrayList of elements in ascending order. We'll look at two examples—one with integer values and another with string values. Input 1 Points[50, 29, 35, 11, 78, 64, 89, 67] Output 1 Points (ascending)[11, 29, 35, ... Read More
11K+ Views
In this article, let's learn how to check if a JSON object has any values or not in Java. If you don't know about JSON, refer JSON. We will use the org.json library and its methods like isEmpty(), length(), and keys() to check if a JSON object is empty or not. We can check if a JSON object is empty or not using the following methods: Using isEmpty() method Using length() method Using keys() method Let's see how to use each of them one by one. ... Read More
31K+ Views
We often need to extract values from a JSON object. In this article, we will learn how to get the values of the different types from a JSON object in Java. What is JSONObject? Java JSONObject is a class in the org.json package that represents a JSON object. Refer JSONObject for more information. Let's see the steps to get the values of different types from a JSON object in Java. Getting different values from a JSON object Before we start, let's add the required library to our program. We can add a .jar file, or we can use a Maven ... Read More
541 Views
A JSONStringer provides a convenient way of producing JSON text, and it can strictly follow to JSON syntax rules. Each instance of JSONStringer can produce one JSON text. A JSONStringer instance provides a value method for appending values to the text and a key-method for adding keys before values in objects. We have array () and endArray() methods that create and bind array values, and object() and endObject () methods that create and bind object values. It is part of the org.json library. It is generally used in Android and lightweight Java programs. In this article, we will learn when to use a JSONStringer in Java. When to use ... Read More
9K+ Views
In this article, we will learn how to sort a JSON array in Java. But first, let’s understand what JSON is. If you do not have knowledge about JSON, you can refer to the tutorial JSON Overview. Now, let's see different ways to sort a JSON array in Java. Ways to sort a JSON array in Java Following are different ways to sort a JSON array in Java - Sort JSON array Without any Dependency Using org.json library: Methods are getJSONArray() and getJSONObject() Using Gson library: Methods ... Read More
1K+ Views
C++ interview questions on ConstructorsWhat is a constructor?A constructor is a function of a class that has the same name as the class. The constructor is called at the time of the initialization of object. There are three types of constructors −Default constructorParameterized constructorCopy constructorSyntaxclass cl_name{ cl_name(){ //This is constructor.. } }What is a destructor?A destructor is a method of a class that has the same name as the class preceded by a tild ~ symbol. It is called at the end of code or when the object is destroyed or goes out of scope.Syntaxclass ... Read More
2K+ Views
Numerical implementation of a decimal number is a float point number. In C++ programming language the size of a float is 32 bits. And there are some floating point manipulation functions that work on floating-point numbers. Here we have introduced some of the floating-point manipulation functions.fmod()The fmod() function operating on floats will return the remainder of the division of the passed arguments of the method.Example Live Demo#include #include using namespace std; int main() { float a, b, rem; a = 23.4; b = 4.1; rem = fmod(a,b); cout
750 Views
A stack is a data structure that stores elements. There are two operations on the stack. push that adds a new element to the stack. pop that removes an element from the stack.The stack can grow upward and downward according to the nature of the program that uses it. The program to find the direction of the growth of stack in a program.AlgorithmStep 1: Create a local variable in the main function. Step 2: Create a function that with a local variable. Step 3: Call the function from the main function. And then compare the local variables of in both ... Read More
9K+ Views
In the C programming language, the programmer can excess the files and read and write content in them.A file is a simple memory block that can store information, here we are concerned with text only.In this program, we will compare two files and report mismatches that occur. These files are almost identical but may have some characters that are different. Also, the program will return the line and position of the file at which the first mismatch occurs.AlgorithmStep 1: Open both the file with pointer at the starting. Step 2: Fetch data from file as characters one by one. Step ... Read More
1K+ Views
In Programing when a program malfunction and runs unusually in the terminal compiler the programmer has the power to explicitly stop the program from running. For explicitly stopping the program, the user must know the right keyboard shortcut that is needed to be pressed.To terminate the execution of a block of code, there are two types of keyboard shortcuts used.Ctrl+c − It is used to stop the execution of the program, it take a bit of time to complete the i/o operations and then suspends the execution. It sends a SIGINT signal to the process which gets terminated. In some ... Read More