The javax.json package provides an Object Model API to process JSON. The Object Model API is a high-level API that provides immutable object models for JSON object and array structures. These JSON structures can be represented as object models using JsonObject and JsonArray interfaces. We can use the JsonGenerator interface to write the JSON data to an output in a streaming way. The JsonGenerator.PRETTY_PRINTING is a configuration property to generate JSON prettily.We can implement a pretty print JSON in the below example.Exampleimport java.io.*; import java.util.*; import javax.json.*; import javax.json.stream.*; public class JSONPrettyPrintTest { public static void main(String args[]) { String jsonString = ... Read More
Following is the Java Program for Recursive Insertion Sort −Example Live Demoimport java.util.Arrays; public class Demo{ static void recursive_ins_sort(int my_arr[], int arr_len){ if (arr_len = 0 && my_arr[j] > last){ my_arr[j+1] = my_arr[j]; j--; } my_arr[j+1] = last; } public static void main(String[] args){ int my_arr[] = {11, 23, 67, 83, 42, 11, 0}; recursive_ins_sort(my_arr, my_arr.length); System.out.println("The array elements after implementing insertion sort is "); System.out.println(Arrays.toString(my_arr)); } }OutputThe ... Read More
Following is the Java program for largest K digit number divisible by X −Example Live Demoimport java.io.*; import java.lang.*; public class Demo{ public static int largest_k(int val_1, int val_2){ int i = 10; int MAX = (int)Math.pow(i, val_2) - 1; return (MAX - (MAX % val_1)); } public static void main(String[] args){ int val_1 = 25; int val_2 = 2; System.out.println("The largest 2 digit number divisible by 25 is "); System.out.println((int)largest_k(val_1, val_2)); } }OutputThe largest 2 ... Read More
The Streaming API consists of an important interface JsonParser and this interface contains methods to parse JSON in a streaming way and provides forward, read-only access to JSON data. The Json class contains the methods to create parsers from input sources. We can parse a JSON using the static method createParser() of Json class.Syntaxpublic static JsonParser createParser(Reader reader)Exampleimport java.io.*; import javax.json.Json; import javax.json.stream.JsonParser; import javax.json.stream.JsonParser.Event; public class JSONParseringTest { public static void main(String[] args) { String jsonString = "{\"name\":\"Adithya\", \"employeeId\":\"115\", \"age\":\"30\"}"; JsonParser parser = Json.createParser(new StringReader(jsonString)); while(parser.hasNext()) { Event event = ... Read More
Here we will see how to check whether a matrix is invertible or not. If one matrix is M, then the inverted matrix M-1 will be −$$M^-1=\frac{adj(M)}{|M\lvert}$$So if the determinant of M is non-zero, then only we can get the inverse, otherwise, we will not get the inverse of it. So here we have to check the determinant is non-zero or not. Finding a determinant is one recursive process. We have to find submatrix, then find the determinant of it, then use that result for the final calculation. Let us see the code to get a better idea.Example Live Demo#include ... Read More
Large volumes of structured and unstructured data are essentially referred to as ‘Big Data;’ and is produced by almost all sources around us such as social media exchange, digital processes, mobile devices, sensors etc. Big Data provides insights into patterns, trends, and correlations with other entities in the business world. Big Data swamps businesses on a regular daily basis, and due to the speed and accuracy with which it is analyzed, it leads to enhanced and accurate decisions via tactical business steps. As it is variable and complex and comes from various sources, it is imperative to connect it and ... Read More
In today’s world, the biggest technology trend is the ‘Internet of Things (IoT);’ and true enough it is defining our lives, the way we work; shaping and influencing businesses, and governments too. It is the ‘next big thing’ or is simply being termed as a revolution/progression of the web, and is being touted as far bigger than anyone has been able to fathom in technology, where machine to machine and man to machine interaction is moving towards new heights.GuesstimatesIt is estimated that by 2020 there will be around 26 billion devices (as per the firm Gartner) that will be connected ... Read More
The javax.json.JsonObject interface can represent an immutable JSON object value and provides an unmodifiable map view to the JSON object name/value mappings. A JsonObject instance can be created from an input source using the static method readObject() of javax.json.JsonReader class and also can be created using the static method createObjectBuilder() of javax.json.Json class.Syntaxpublic static JsonObjectBuilder createObjectBuilder()Exampleimport java.io.*; import javax.json.*; public class JsonObjectTest { public static void main(String[] args) throws Exception { JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("Name", "Adithya"); builder.add("Designation", "Python Developer"); builder.add("Company", "TutorialsPoint"); builder.add("Location", "Hyderabad"); JsonObject data = builder.build(); ... Read More
An IP address stands for Internet Protocol Address. Devices are assigned with specified IP Address to identify the device which are connected on internet. Public IP addresses are routable on Internet and are generally provided by an ISP (Internet service provider) which are accessible over the Internet.Do you know how to find public IP address from Linux command line? There are several ways to find and identify public IP address. For example, we can use third party websites or “shell” commands. This article provides simple methods to find public IP address from command line on Linux.Who Uses Public IP Addresses?Public ... Read More
Linux process can be visualized as a running instance of a program where each thread in the Linux is nothing but a flow of execution of the processes. Do you know how to see the number of threads per process on Linux environment? There are several ways to count the number of threads. This article deals with, how to read the information about processes on Linux and also to count the number of threads per process.Read Process InformationTo read the process information use ‘ps’ command. This command is used to read a snapshot of the current processes on Linux. However, ... Read More