Found 7442 Articles for Java

How to find duplicate elements in a Stream in Java

Shriansh Kumar
Updated on 19-Jul-2023 19:06:38

12K+ Views

Finding duplicate elements in a stream of data is one of the common questions that is asked in Java interviews and even in the exams of many students. Java provides several ways to find duplicate elements, we will focus mainly on two ways: the first one is by using Set of Java Collection Framework and the other one is by using the built-in method of stream named Collections.frequency(). Java Program to find duplicate elements in a Stream Before discussing the different ways to get duplicate items from a collection of data, it is necessary to ... Read More

How to Find User Defined Objects From LinkedHashSet in Java?

Shriansh Kumar
Updated on 19-Jul-2023 18:49:36

233 Views

LinkedHashSet is a class of Java Collection Framework that implements the Set interface and extends the HashSet class. It is a linked list type of collection class. It stores and returns the objects in the order in which they were inserted, therefore it does not allow duplicate objects. In this article, we will use the built-in method 'contains()'' to find user-defined objects from LinkedHashSet. The user-defined objects are created with the help of constructors. Java Program to get User-Defined Objects from LinkedHashSet Let's have a brief introduction of two important in-built methods that we will use in our ... Read More

How to Find the Number of Arguments Provided at Runtime in Java?

Shriansh Kumar
Updated on 19-Jul-2023 18:40:22

919 Views

In Java, one way of passing arguments at runtime is by using the command line or terminal. While retrieving those values of command line arguments, we may need to find the number of arguments provided by the user at runtime which is possible with the help of length property. This article aims to explain the process of passing and getting the number of arguments provided by user with the help of example programs. Getting the Number of Arguments provided by User at Runtime Before finding the number of command line arguments, our first step is ... Read More

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

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

2K+ 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

359 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 09-Apr-2025 19:35:54

814 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. Before creating our own annotations, let's familiarize ourselves with the basics of annotations in Java. What are Annotations? Annotations are features of Java that allows us to add ... Read More

How to Fix int cannot be dereferenced Error in Java?

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

6K+ 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

227 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 VB.NET and Java

Shriansh Kumar
Updated on 09-Apr-2025 19:34:30

798 Views

VB.NET and Java are the two widely used programming languages available nowadays. They serve to develop a variety of software including web and android applications. The features and capabilities of both languages make it difficult to choose one over another. In this article, we will compare and analyze them based on some parameters such as syntax, features, performance, and applications to point out the difference between VB.NET and Java. VB.NET vs Java Before discussing the difference between both technologies, let's have a quick introduction about them. VB.NET It is an abbreviation that stands for Visual Basic .NET. It is ... Read More

Difference Between trustStore and keyStore in Java

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

1K+ 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

Advertisements