
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

581 Views
A multi-dimensional array is nothing but an array of arrays, and yes, it is supported by the Java programming language. It is used to store data within a table, grid, or matrix having rows and columns. In Java, these arrays are also called ragged arrays or jagged arrays. Let's understand why Java supports multi-dimensional arrays and their types. Uses of Multidimensional Arrays Multidimensional arrays in Java are used for various purposes, including: Storing data in a tabular format, such as matrices, chessboards, or spreadsheets. Representing complex relationships in data like 3D models. Managing multiple sets of data, like scores ... Read More

209 Views
Array.entries()The Array.entries() in JavaScript is used to get a new Array that contains the key and value pairs for each index of an array. It returns an Array Iterator object with key/value pairs.syntaxarray.entries();ExampleIn the following example elements.entries() method, using for loop, access every element and generate key/value pair of the particular element.To simplify the code we just assigned an iterator variable to elements.entries()..Live Demo var elements = ["Helium", "Neon", "Krypton", "Xenon", "Radon"]; var iterator = elements.entries(); for (let e of iterator) { document.write(e); document.write(""); } Output0, ... Read More

6K+ Views
Math.ceil() and Math.round() methods differ in a way that the former round off a number to its nearest integer in upward direction of rounding(towards the greater value) whereas the latter round off a number to its nearest integer in downward direction of rounding(towards lower value). Let's examine the two methods individually.Math.ceil()Math.ceil() method round off number passed as parameter to its nearest integer so as to get greater value.ExampleIn the below example when a number 5.34 passed as a parameter, Math.ceil() round off it in to 6, which is a greater value than actual number.Live Demo document.write(Math.ceil(5.34)); ... Read More

271 Views
slice()The slice() method extracts a part of a string and returns the extracted part in a new string.It doesn't modify the original string.syntaxslice() takes two parameters one is starting index and the other is ending index. It's notation is given below. string.slice(string.slice(starting index, ending index))Arguments a) starting index: It gives from which index string extraction should be started. b) ending index: It gives before which index string extraction should be ended.Example-1In the following example, slice() method slice the given string in to new string starting from index 18 to 26 (27-1) there by giving "Neuralink" as the output. Live Demo ... Read More

212 Views
substr()substr() method extracts parts of a string, beginning at the character at the specified index, and returns the specified number of characters. It does not change the original string. Syntaxsubstr() method accepts two parameters one is start and other is length str.substr(start , length)Arguments a) Start: start defines the starting index from where the sub string is to be extracted from the base string. b) length: length defines the number of characters to be extracted starting from the start in the given string. If the second argument to the function is ... Read More

284 Views
The String class objects are immutable whereas the StringBuffer and the StringBuilder objects are mutable.A StringBuffer is synchronized while a StringBuilder is not synchronized.A Concatenation operator "+" is internally implemented using either StringBuffer or StringBuilder.If the Object value is not going to change use String Class because a String object is immutable.If the Object value can change and will only be accessed from a single thread, use a StringBuilder because StringBuilder is unsynchronized.If the Object value can change and will be modified by multiple threads, use a StringBuffer because StringBuffer is synchronized.

920 Views
In Java, both String and StringBuffer classes are used to represent sequences of characters. However, the String class is immutable, which means once a String object is created, its value cannot be changed, while the StringBuffer class is mutable. It allows us to modify the contents of the string without creating a new object. In this article, we will discuss why we should use the StringBuffer class instead of String in Java. Why Use StringBuffer Instead of String? A few reasons why StringBuffer is often preferred over String is given below: A StringBuffer is thread-safe ... Read More

6K+ Views
The Heap Memory and String Constant Pool are two different memory locations in Java where objects are stored during the execution of programs. Both memory areas are managed by the Java Virtual Machine. In this article, we are going to discuss the difference between Heap Memory and String Constant Pool in Java. Heap Memory Heap memory is a runtime data area from which memory for all class instances and arrays is allocated. It is the main memory area used for dynamic memory allocation in Java. Example Creating strings with the new keyword always allocates new memory in the heap. In ... Read More

2K+ Views
In Java, the string literals (or, string objects) are stored in a separate memory area called string constant pool to improve the performance of string operations and optimize the memory while using them. Let's understand how. Creating String Objects in Java There are two ways to create a String object in Java: Using the new operator Using String literal Example The example given below shows how to create a string object: public class Example { public static void main(String[] args) { ... Read More

9K+ Views
The general meaning of immutable is something that cannot be changed or modified after creation. In Java, a string is immutable; we cannot change the object itself, but we can change the reference to the object. The string is made final to not allow others to extend and modify it. When you modify a string, a new copy of the string with your modifications is created. This article will explain what a String is and why it is immutable and final in Java. What is a String? Like other object-oriented programming languages, almost every component of Java is an object, ... Read More