Server Side Programming Articles - Page 1571 of 2650

Parent and Child classes having same data member in Java

AmitDiwan
Updated on 14-Sep-2020 09:16:11

12K+ Views

The parent class can hold reference to both the parent and child objects. If a parent class variable holds reference of the child class, and the value is present in both the classes, in general, the reference belongs to the parent class variable. This is due to the run-time polymorphism characteristic in Java.ExampleFollowing is an example − Live Democlass Demo_base {    int value = 1000;    Demo_base() {       System.out.println("This is the base class constructor");    } } class Demo_inherits extends Demo_base {    int value = 10;    Demo_inherits() {       System.out.println("This is the inherited ... Read More

Parallel Data Processing in Java

Alshifa Hasnain
Updated on 19-Mar-2025 18:53:20

1K+ Views

In this article, we will learn about Parallel Data Processing in Java. Parallel processing of data is important to increase performance, particularly for large amounts of data. Java has its own built-in ways to accomplish things in the background, fully using multi-core processors. Different Approaches The following are the two different approaches for parallel data processing in Java − Using Java Streams API Using Arrays.parallelSort() Why Parallel Processing? Parallel data processing is essential in scenarios where − Processing large datasets is necessary to happen ... Read More

NavigableMap Interface in Java with Example

AmitDiwan
Updated on 14-Sep-2020 09:11:24

757 Views

NavigableMap is an extension of the SortedMap collection framework. It is used to arrange the elements in a uniform fashion. NavigableMap has different methods to iterate over the elements in the Map.ExampleFollowing is an example − Live Demoimport java.util.NavigableMap; import java.util.TreeMap; public class Demo {    public static void main(String[] args) {       NavigableMap my_map = new TreeMap();       my_map.put("A", 856);       my_map.put("M", 349);       my_map.put("Z", 567);       System.out.printf("The descending set is : %s%n", my_map.descendingKeySet());       System.out.printf("The floor entry is : %s%n", my_map.floorEntry("A"));       System.out.printf("The first key ... Read More

Non-generic Vs Generic Collection in Java

Alshifa Hasnain
Updated on 19-Mar-2025 18:53:35

3K+ Views

In this article, we will learn about the collections in Java. The collections are used to store and manipulate groups of objects. Java collections can be broadly classified into two types − Non-generic Collections (Before Java 5) Generic Collections (Introduced in Java 5) Non-generic collections allow storing objects of different types leading to runtime errors. On the other hand generic collections enforce type safety at compile-time, reducing the risk of type-related errors.  Non - Generic Collection When the data structure is non-generic, it causes issues when the data is tried ... Read More

Method Overloading and null error in Java

AmitDiwan
Updated on 14-Sep-2020 08:55:40

879 Views

When method is overloaded in Java, the functions have the same name, and the number of parameters to the function is same. In such cases, if the parameters are non-primitive and have the ability to accept null values, the compiler gets confused when the function is called with a null value, since it can’t choose either of them, because both of them have the ability to accept null values. This results in a compile time error.ExampleBelow is an example showing the same − Live Demopublic class Demo {    public void my_function(Integer i) {       System.out.println("The function with integer ... Read More

Multiset Interface – Java

AmitDiwan
Updated on 14-Sep-2020 08:53:29

1K+ Views

Multiset is a collection in Java, that helps in order-independent equality, similar to Set structure. But the only difference is that a multiset can also contain duplicate elements.If multiset is visualized as a list, then this wouldn’t be the case since lists can’t hold duplicate values, and list elements are always in a specific order.Multiset can be thought of as a collection that lies somewhere between a list and a set structure. In multiset, the duplicates values are allowed, and there is no guarantee that the elements in a multiset would occur in a specific order. Multiset is also known ... Read More

MultiMap in Java

AmitDiwan
Updated on 14-Sep-2020 08:51:49

310 Views

Multimap is a general method to bind the keys with random multiple values. The Multimap framework in Guava has methods that help in dealing with mapping keys to multiple values. Multimap can be visualized as a framework that −Is a collection of mapping from one key to one specific valueIs a collection of mapping from unique key to multiple values, i.e. collection of values.It can be implemented in places that use Map.Advantages of MultimapAn empty collection need not be populated before added a key value pair with the help of the function ‘put’.The ‘get’ method doesn’t return a null, except ... Read More

Multidimensional Collections in Java

Alshifa Hasnain
Updated on 19-Mar-2025 18:52:59

3K+ Views

In this article, we will learn about multidimensional collections in Java. These collections offer dynamic resizing, flexible data storage, and better memory management compared to traditional arrays. What are Multidimensional collections? Multidimensional collections are also known as Nested collections. It is a group of objects wherein every group has any number of objects that can be created dynamically. They can be stored in any position as well. In the case of arrays, the user would be bound to a specific number of rows and columns, hence multidimensional structure helps create and add elements dynamically. Different Approaches The following are the ... Read More

Searching characters and substring in a String in Java

AmitDiwan
Updated on 14-Sep-2020 08:44:41

651 Views

Following is the Java program to search characters and substring in a string −Example Live Demoimport java.io.*; import java.lang.*; public class Demo {    public static void main (String[] args) {       String test_str = "Hello";       CharSequence seq = "He";       boolean bool_1 = test_str.contains(seq);       System.out.println("Was the substring found? " + bool_1);       boolean bool_2 = test_str.contains("Lo");       System.out.println("Was the substring found? " + bool_2);    } }OutputWas the substring found? true Was the substring found? FalseA class named Demo contains the main function. Here, a string ... Read More

Local Variable Type Inference or LVTI in Java 10

AmitDiwan
Updated on 14-Sep-2020 08:36:17

444 Views

Type inference in Java refers to the automatic detection of the variable’s datatype. This automatic detection usually happens at compile time. It is a feature of Java 10 and it allows the developer to skip declaring the type that is associated with the local variables. Local variables are those which are defined inside a method, initialization block, in for-loops, etc. The type would be usually identified by JDK.Upto Java 9, the following syntax was used to define local variable of a class type −class_name variable_name = new class_name(Arguments);This way, the type of the object would be specified on the right ... Read More

Advertisements