Found 7442 Articles for Java

Difference Between URI and URN in Java

Shriansh Kumar
Updated on 21-Jul-2023 21:13:59

153 Views

The modern day Internet is all about the World Wide Web which holds billions of website and resources. There are several ways to access those web-based resources by following the protocols. Java has the concept of networking that is used to establish communication between clients and those resources. But, to locate a specific resource among the millions available, we need a unique identifier. There are three components: URI, URL and URN that helps us locate a certain resource on the web. This article aims to explain the difference between URI and URN in Java. URI vs URN in Java URI ... Read More

Difference Between JavaEE and Spring

Shriansh Kumar
Updated on 21-Jul-2023 21:04:32

1K+ Views

The debate about JavaEE and Spring is very common among Java developers. Both technologies emerged as popular frameworks for building enterprise applications using Java. Java EE is a more adaptable and distributed framework for developing big software. Spring, on the other hand, is open source and makes use of the POJO programming model to develop any type of Java application. Let’s find out more detailed differences between JavaEE and Spring through this article. JavaEE vs Spring JavaEE Java Platform Enterprise Edition, in short JavaEE is a set of specifications defined by Oracle. It is also known as J2EE. It aims ... Read More

Getting Set View of Keys from HashMap in Java

Shriansh Kumar
Updated on 21-Jul-2023 20:39:59

723 Views

To get the set view of keys from a HashMap in Java, we can use the in-built method named ‘keySet()’. Here, the HashMap is a class that is used to implement Map Interface. It stores its element in key-value pairs. The Key is an object that is used to fetch and receive value associated with it. It has access to all the methods of Map Interface, it does not have any additional methods of its own. Duplicate values are not allowed, although we can store null values and keys. Java Program to Get Set View of Keys from HashMap keySet() ... Read More

Getting Synchronized Map from Java HashMap

Shriansh Kumar
Updated on 21-Jul-2023 20:32:34

3K+ Views

To get the synchronized Map from a Hash Map in Java, we can use an in-built method of Collection interface named ‘synchronized Map()’. Here, the Hash Map is a class that is used to implement Map Interface. It stores its element in key-value pairs. The Key is an object that is used to fetch and receive value associated with it. It has access to all the methods of Map Interface, it does not have any additional methods of its own. Duplicate values are not allowed, although we can store null values and keys. In this article, we will explore the ... Read More

Getting Synchronized Map from Java TreeMap

Shriansh Kumar
Updated on 21-Jul-2023 20:28:31

473 Views

To get the synchronized Map from a TreeMap in Java, we can use an in-built method of Collection interface called ‘synchronizedMap()’. Here, TreeMap is a class that is used to implement NavigableMap Interface. It stores the elements of the map in a tree structure. It provides an efficient alternative to store the key-value pairs in sorted order. By default, a TreeMap is not synchronized. In this article, we will explain the need for synchronization and its practical implementation through example programs. Synchronized Map from a Tree Map A Tree Map is not thread-safe which means when we implement it in ... Read More

How Objects Can an ArrayList Hold in Java?

Shriansh Kumar
Updated on 21-Jul-2023 20:25:30

211 Views

ArrayList is a class of Java Collection Framework that implements List Interface. It is a linear structure that stores and accesses each object in a sequential manner. It allows the storage of duplicate values. Always remember, each class of the collection framework can hold instances of wrapper classes or custom objects. They do not work with primitives. This article aims to explain how those objects hold by an ArrayList in Java. How ArrayList holds Objects ArrayList internally uses an array to store its elements. However, the size of the array is not fixed, it can increase and decrease as per ... Read More

Different Approaches to Concurrent Programming in Java

Shriansh Kumar
Updated on 21-Jul-2023 20:07:38

301 Views

In Java, concurrent programming is a technique that allows multiple tasks or processes to run simultaneously on a single processor or multiple processors. It can improve the performance and responsiveness of applications. However, it also introduces new challenges and complexities to the Java developers, such as synchronization and deadlock. In this article, we will explore some of the different approaches to concurrent programming such as multithreading and executors. Concurrent Programming in Java The following three components of Java are used for Concurrent Programming java.lang.Thread clas java.lang.Runnable java.util.concurrent Multithreading It is a feature of the Java programming language that ... Read More

Different Ways to Achieve Pass By Reference in Java

Shriansh Kumar
Updated on 21-Jul-2023 19:56:29

1K+ Views

The most frequent query asked by beginner programmers, especially those who have already worked with C and C++ in the past, is whether Java supports pass-by-referenceor pass-by-value. Generally, programming languages use pass-by-value and pass-byreferencefor passing parameters to a method. However, Java does not support both approaches rather it uses pass-by-value to pass both primitive and reference type values. But, it provides a few ways to achieve pass-by-reference, we will explore those through this article. Ways to Achieve Paas By Reference Let’s start this discussion by understanding the storage mechanism of Java. The reference variables, names of methods and classes are ... Read More

How Java filter() Method Works in Background?

Shriansh Kumar
Updated on 21-Jul-2023 19:52:32

440 Views

The Java filter() method allows us to strain elements of the stream based on the specified condition. It is a part of higher-order function that is used to apply a certain behavior on stream items. This method takes a predicate as an argument and returns a list of elements that match the predicate. But the question arises here is that how this filter() method works in the background. This article aims to explain this question through some example programs. Working of filter() method in Background Before going deep into the filter() method, let’s familiarize ourselves with I/O Streams. Itis an ... Read More

How HashTable Works Internally in Java?

Shriansh Kumar
Updated on 20-Jul-2023 22:15:06

3K+ Views

The Hashtable class is a part of the Java Collection Framework that stores its element in key-value pairs in a hash table. The Key is an object that can be used to fetch and receive value associated with it. There exist a few similarities between a Hashtable and HashMapclass but Hash table is synchronized. Also, its keys must be associated with values, they could not be null. This article aims to explain how Hash table works internally in Java. Working of Hashtable in Java We can consider a Hashtable as an array of buckets, where each bucket contains a list ... Read More

Advertisements