Found 9326 Articles for Object Oriented Programming

How to determine length or size of an Array in Java?

Shriansh Kumar
Updated on 19-Jul-2023 18:26:08

932 Views

In Java, one of the convenient ways to determine the length or size of an array is by using its length property. It counts the number of elements stored in an array and returns the count. Finding the length of an array is one of the common yet crucial operation as it is used to find the number of elements of an array, append new elements into it and retrieve stored items. This article aims to explain the various ways to get the length or size of an array. Java Program to determine the length or size of an Array ... Read More

How to Create TreeMap Objects using Comparable Interface in Java?

Shriansh Kumar
Updated on 19-Jul-2023 18:11:04

170 Views

TreeMap is a class of Java Collection Framework that implements NavigableMap Interface. It stores the elements of the map in a tree structure and provides an efficient alternative to store the key-value pairs in sorted order. Note that while creating objects of TreeMap we need to use the comparable interface so that we can maintain the sorting order of its elements. In this article, we are going to discuss a few Java programs to create TreeMap objects using comparable interface. Java Program to create TreeMap Objects using Comparable Interface Before jumping to the Java program ... Read More

How to Create Your Own Annotations in Java?

Shriansh Kumar
Updated on 19-Jul-2023 18:07:51

371 Views

When we start learning Java, we often wonder about symbols like @override and @inherited. They are a special kind of tag termed as Annotations that can be applied to classes, methods, fields, parameters, and other elements of the code. Java provides support for some built-in annotations, however, we are allowed to create our own annotations too. In this article, we are going learn how to create and use our own custom annotations. Creating Custom Annotations in Java Before creating our own annotations, let's familiarize ourselves with the basics of annotations in Java. Annotations They are ... Read More

How to Fix int cannot be dereferenced Error in Java?

Shriansh Kumar
Updated on 19-Jul-2023 17:56:33

4K+ Views

"int cannot be dereferenced", a common error in Java that may occur while converting a variable of integer type into String or while comparing it with other primitive type variables. It might be difficult to debug for a beginner programmer, but once we get the alternative ways of converting and comparing integers, it will become a piece of cake for us. Try to stick with us till the end of this article to find the reasons and possible solutions for fixing the 'int cannot be dereferenced error'. How to Fix int cannot be dereferenced Error in Java ... Read More

Different Ways to Capture Java Heap Dumps

Shriansh Kumar
Updated on 19-Jul-2023 17:51:49

105 Views

A heap dump is a snapshot of the memory more specifically the Java heap memory of a Java process at a certain point in time. It contains information about the Java objects and classes. Heap dumps are useful when we need to debug memory problems such as memory leaks, high memory consumption, and out of memory errors. Java provides several ways to capture these heap dumps that we are going to explore in this article. Ways to Capture Java Heap Dumps The following ways can be used to capture Java heap dumps: ... Read More

Difference Between trustStore and keyStore in Java

Shriansh Kumar
Updated on 19-Jul-2023 17:41:38

498 Views

If one is a Java developer and has worked with the Java SSL/TLS, one may have encountered the terms trustStore and keyStore. These two files are used to store cryptographic keys and certificates. Till Java 8, the default format for these files was JKS. With the release of Java 9, the default format changed to PKCS12. Here, JKS is a Java specific format, whereas the PKCS12 is a language independent format. In this article, we will discuss the difference between trustStore and keyStore in Java. trustStore vs keyStore trustStore It is a file ... Read More

Difference Between State and Strategy Design Pattern in Java

Shriansh Kumar
Updated on 19-Jul-2023 17:39:23

245 Views

Being a Java developer, one might have encountered some design patterns that help us in structuring our code and make it more reusable and maintainable. Two of these design patterns are the State pattern and the Strategy pattern. The use case of these design patterns is almost the same. However, they are different from each other in many ways. In this article, we are going to explore the differences between state and strategy design patterns in Java. State vs Strategy Design Pattern State Design Pattern The State pattern is a behavioral design pattern that allows an object ... Read More

Difference Between RMI and DCOM

Shriansh Kumar
Updated on 19-Jul-2023 17:37:25

142 Views

Both RMI and DCOM are the technologies that serve to enable distributed object computing. The RMI is a Java-based technology, DCOM, on the other hand, is developed by Microsoft. Although they are built for the same purpose by two technical market giants, there exist some significant differences in terms of design, implementation and usage. We are going to compare and list some differences between RMI and DCOM in this article. RMI vs DCOM Distributed Objects To understand the differences between RMI and DCOM, it is necessary to understand distributed object computing as both terms come under the same umbrella. ... Read More

Working with UDP DatagramSockets in Java

Siva Sai
Updated on 19-Jul-2023 21:36:39

422 Views

Introduction Networking is a critical component of modern software development. In Java, one of the ways we can establish network communication is by using sockets. While most are familiar with stream-oriented, connection-based TCP sockets, this article focuses on the connectionless, packet-oriented UDP DatagramSockets and how to work with them effectively. Understanding UDP and DatagramSockets User Datagram Protocol (UDP) is one of the core protocols in the Internet Protocol Suite. Unlike TCP, it is connectionless and does not guarantee delivery, order, or error-checking of data packets. However, it is faster and more efficient for lightweight or time-sensitive applications In Java, the ... Read More

What is Java Parallel Streams?

Siva Sai
Updated on 19-Jul-2023 21:19:53

727 Views

Introduction Parallel processing is a cornerstone of modern computing, allowing us to take full advantage of multi-core systems. In the realm of Java, one of the tools at our disposal to utilize this power is parallel streams. This article delves into the concept of parallel streams in Java, exploring their functionality, benefits, and how to use them effectively. Understanding Java Parallel Streams Java Streams were introduced in Java 8 as a way to perform complex data processing tasks on collections of objects, often referred to as a stream of data. These operations can be executed sequentially or in parallel. A ... Read More

Advertisements