
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 9150 Articles for Object Oriented Programming

9K+ Views
The Jackson @JsonIgnore annotation can be used to ignore a certain property or field of a Java object. The property can be ignored both when reading JSON into Java objects and when writing Java objects into JSON. We can use the readValue() and writeValueAsString() methods of ObjectMapper class to read a JSON to Java Object and to write a Java object to JSON.Syntax@Target(value={ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD}) @Retention(value=RUNTIME) public @interface JsonIgnoreExampleimport java.io.*; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; public class JsonIgnoreTest { public static void main(String[] args) throws IOException { Customer customer = new Customer("110", "Surya Kiran", "Chennai"); System.out.println(customer); ... Read More

981 Views
The @JsonProperty annotation can be used to indicate the property name in JSON. This annotation can be used for a constructor or factory method. The @JsonCreator annotation is useful in situations where the @JsonSetter annotation cannot be used. For instance, immutable objects do not have any setter methods, so they need their initial values injected into the constructor.@JsonProperty - ConstructorExampleimport com.fasterxml.jackson.annotation.*; import java.io.IOException; import com.fasterxml.jackson.databind.*; public class JsonCreatorTest1 { public static void main(String[] args) throws IOException { ObjectMapper om = new ObjectMapper(); String jsonString = "{\"id\":\"101\", \"fullname\":\"Ravi Chandra\", \"location\":\"Pune\"}"; System.out.println("JSON: " + jsonString); ... Read More

722 Views
JavaScript programming language that is usually used for web scripting. It is a lightweight, interpreted programming language. JavaScript is one of the most programming languages for web development. For running JavaScript each browser has its own engine which enables the proper functioning of JavaScript in the browser. Some common Browsers and their JavaScript engines are −Spider Monkey for firefoxV8 for Google ChromeJavaScript code for SafariChakra for Microsoft Internet Explorer/ edgeTo make JavaScript universe and stop a browser from describing their own scripts. There is a standard set for JavaScript which will be used throughout the browser. there is an Association ... Read More

1K+ Views
A JSONObject is an unordered collection of name/value pairs and parses text from a String to produce a map-like object. However, we can auto-increment the property of a JSONObject using the increment() method of JSONObject class. If there is no such property, create one with a value of 1. If there is such a property and if it is an Integer, Long, Double or Float then add one to it.Syntaxpublic JSONObject increment(java.lang.String key) throws JSONExceptionExampleimport org.json.JSONException; import org.json.JSONObject; public class IncrementJSONObjectTest { public static void main(String[] args) throws JSONException { JSONObject jsonObj = new JSONObject(); jsonObj.put("year", 2019); ... Read More

1K+ Views
The JSON is one of the widely used data-interchange formats and is a lightweight and language independent. We can convert a JSONObject to cookie using the toString() method and convert a cookie to JSONObject using the toJSONObject() method of org.json.Cookie class.Convert JSONObject to cookieSyntaxpublic static java.lang.String toString(JSONObject jo) throws JSONExceptionExampleimport org.json.Cookie; import org.json.JSONObject; public class JSONObjectToCookieTest { public static void main(String args[]) { JSONObject jsonObject = new JSONObject(); jsonObject.put("path", "/"); jsonObject.put("expires", "Thu, 07 May 2020 12:00:00 UTC"); jsonObject.put("name", "username"); jsonObject.put("value", "Adithya"); String cookie = Cookie.toString(jsonObject); ... Read More

616 Views
When you have created an array of a particular data type with fixed size and populate it if you store a value other than its datatype an ArrayStoreException is thrown at the run time.ExampleIn the following Java program, we are creating an Integer array and trying to store a double value in it. Live Demoimport java.util.Arrays; public class ArrayStoreExceptionExample { public static void main(String args[]) { Number integerArray[] = new Integer[3]; integerArray[0] = 12548; integerArray[1] = 36987; integerArray[2] = 555.50; integerArray[3] = 12548; ... Read More

4K+ Views
No, HashMap does not allow duplicate keys. The HashMap is a class that implements the Map interface. It is based on the Hash table. It is used to store key-value pairs. It allows null keys and values, but it does not allow duplicate keys. You can store key-value pairs in the HashMap object. Once you do so, you can retrieve the values of the respective keys, but the values we use for keys should be unique. Let's understand what will happen if we try to add a duplicate key into a HashMap.Addng a duplicate key to a HashMapThe put() method ... Read More

1K+ Views
The ArrayList class in Java is a Resizable-array implementation of the List interface. It allows null values. Java clear() Method V/S removeAll() Method There are some important differences between the clear() and removeAll (Collection c) methods of the ArrayList class. This table compares these two methods. Key clear() removeAll() ... Read More

42K+ Views
Jackson is a Java library that is used to convert JSON to Java objects and vice versa. Conversion of JSON to a Java object is called deserialization, and Java object to JSON is known as serialization. Both of these tasks can be done by using the Jackson library. In this article, we are going to learn how to convert JSON to Java objects using the Jackson library. Jackson Library: Convert a JSON to a Java Object The ObjectMapper class belongs to the Jackson library. This class is responsible for the serialization and deserialization of Java objects. The ObjectMapper class is used ... Read More

834 Views
The Console class is part of the Java.io package and is used to read input from the keyboard or user and write output to the console. Unlike Scanner, the Console class provides methods to read text and passwords. If you read a password using the Console class, it will not be displayed to the user (without showing the typed characters). To use the Console class, we need its object, and the Console object is obtained by calling System.console() as shown below - Console console = System.console(); Note: If you try to execute the program in a non-interactive environment like an IDE, it doesn’t work. It ... Read More