Found 9150 Articles for Object Oriented Programming

What is the differences between TreeMap, HashMap and LinkedHashMap in Java?

Nitin Sharma
Updated on 18-Sep-2019 14:36:22

1K+ Views

HashSet and ArrayList both are one of the most important classes of the Java Collection framework.The following are the important differences between TreeMap, HashMap and LinkedHashMap.Sr. No.KeyTreeMapHashMapLinkedHashMap1Ordering of elementsThe elements inserted in TreeMap are sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.In case of HashMap it does not guarantees as to the order of the map also it does not guarantee that the order will remain constant over time.LinkedHashMap follows the insertion order of elements and also maintaining an order of elements inserted into ... Read More

What is the syntax to define enums in javascript?

Arnab Chakraborty
Updated on 23-Aug-2022 08:09:44

15K+ Views

Enums or Enumerated types are special data types that set variables as a set of predefined constants. In other languages enumerated data types are provided to use in this application. Javascript does not have enum types directly in it, but we can implement similar types like enums through javascript. In this article, we shall cover the syntaxes and uses to define enumerated types in javascript. Below the syntax is given to show a basic implementation of enums in javascript, we can define an object to encapsulate the enumerated type, and assign keys for each enum value. Syntax const EnumType ... Read More

What is javascript version of sleep()?

Arnab Chakraborty
Updated on 23-Aug-2022 07:59:27

793 Views

Sometimes we perform certain tasks in any language by maintaining a time delay. For instance, we are making a timer application that will update each second. In such cases, we wait for a second and update the second timer one by one. We also call this delay or sleep().In some other languages like Java, there is a sleep() function that is used to wait for some time. In this article, we shall see what is the equivalent method of sleep in javascript. Let us follow the syntaxes for delay generation Syntax (Defining a function) function sleep(t: the time in ... Read More

What is the differences between HashMap and HashTable in Java

Nitin Sharma
Updated on 18-Sep-2019 14:35:37

910 Views

HashMap and HashTable both are one of the most important classes of Java Collection framework. Both HashMap and HashTable stores the data in key value pair and at the time storing data hashing is used to hash the key and the resulting hash code is used as the index at which the value is stored within the table. But still, there are many differences between both these classes which we would discuss below.The following are the important differences between HashMap and HashTable.Sr. No.KeyHashMapHashTable1IntroductionHashmap is the advanced version of HashTable and is introduced as a new class in JDK 1.2.HashTable on ... Read More

What is the most efficient way to deep clone an object in JavaScript?

Abdul Rawoof
Updated on 26-Aug-2022 11:57:23

1K+ Views

In JavaScript, objects are the collection of a key value pairs. The properties of the object are the keys and is denoted with a string. The value of the key is the value of the property of the given object. In JavaScript, the objects can be copied to other by many ways in which some of them are discussed below. Using spread operator(…), Using assign() function and Using JSON.parse() and JSON.stringify() functions. Using the Json.parse() and Stingify() methods Among the above mentioned three ways, for an object to be deep cloned, JSON.stringify() and JSON.parse() functions are used. ... Read More

Difference Between var and let in JavaScript

Nitin Sharma
Updated on 22-Nov-2024 14:53:19

4K+ Views

To declare a variable in javascript we can use var, let or const keyword. Earlier var was only way to declare variable in javascript.In ES6, let and const keywords were introduced as a better way to declare variables. Now it is advised to use let instead of var to declare a variable. In this article we will be understanding the differences between var and let in Javascript. We will be differentiating between let and var based on the features mentioned in the table: ... Read More

Difference between TypeScript and JavaScript

Kiran Kumar Panigrahi
Updated on 25-Aug-2022 12:53:24

2K+ Views

Both TypeScript and JavaScript are used at the client-end for processing the server requests and rendering data on UI. Both are scripting languages, however Typescript supports some additional features, due to which it is sometimes regarded as the superset of JavaScript. Read through this article to find out more about TypeScript and JavaScript and how these two languages are different from each other. What is JavaScript? JavaScript is most often used as a component of webpages. Its webpage implementations enable client-side script to interact with the user and create dynamic sites. It is a programming language that is ... Read More

How to pretty print json using javascript?

Arnab Chakraborty
Updated on 23-Aug-2022 07:54:16

963 Views

Java Script Object Notation is one of the many standard formats to store data in different many applications. JavaScript objects can also be stored in a file in this JSON format. In this article, we will cover a few methods to print the JSON objects in a pretty method. Let us see this as an example. We are creating an object in javascript before − Example (Creating Javascript Object)

Difference between throw and throws in Java

Nitin Sharma
Updated on 18-Sep-2019 14:29:22

11K+ Views

Both throw and throws are the concepts of exception handing in which throw is used to explicitly throw an exception from a method or any block of code while throws are used in the signature of the method to indicate that this method might throw one of the listed type exceptions.The following are the important differences between throw and throws.Sr. No.Keythrowthrows1DefinitionThrow is a keyword which is used to throw an exception explicitly in the program inside a function or inside a block of code.Throws is a keyword used in the method signature used to declare an exception which might get ... Read More

Difference between Thread.start() and Thread.run() in Java.

Nitin Sharma
Updated on 18-Sep-2019 14:28:24

6K+ Views

As we know that start() and run() are the two important methods of multithreading and one is used to create a new thread while other is used to start executing that thread.Following are the important differences between Thread.start() and Thread.run().Sr. No.Keystart()run()1Implementationstart method of thread class is implemented as when it is called a new Thread is created and code inside run() method is executed in that new Thread.While if run method is executed directly than no new Thread is created and code inside run() will execute on current Thread and no multi-threading will take place.2Definitionstart method is defined in thread ... Read More

Advertisements