Found 9171 Articles for Object Oriented Programming

How to Print all Keys of the LinkedHashMap in Java?

Adeeba Khan
Updated on 25-Aug-2023 17:22:17

2K+ Views

Java's LinkedHashMap data structure combines the strengths of a HashMap as well as of a doubly-linked list. It is one of the better options for situations requiring predictable iteration as it not only offers key-value mapping like a HashMap but also preserves the insertion order of components. There are times when we need to print every key found in a LinkedHashMap for multiple reasons, that include debugging, analysis and information display to users. In this post, we will examine two excellent techniques that let us print every key from a LinkedHashMap in Java, enabling us to effectively extract and visualize ... Read More

How to Prevent the Addition of Duplicate Elements to the Java ArrayList?

Adeeba Khan
Updated on 25-Aug-2023 17:19:53

3K+ Views

Widely used Java ArrayLists are data structures that offer dynamic arrays, enabling simple element manipulation. It is sometimes necessary to stop duplicate elements from being added to an ArrayList, though. Duplicate parts can cause your programme to behave unexpectedly, produce erroneous results, and use wasteful algorithms. This article will examine two methods to avoid adding duplicate components to a Java ArrayList, arming you with the information and resources you need to maintain data integrity and write cleaner code. Multiple disadvantages may result from adding duplicate elements to an array list. First, it might result in redundant data, which would use ... Read More

How to Print all Mappings of the LinkedHashMap in Java?

Adeeba Khan
Updated on 25-Aug-2023 17:29:29

536 Views

In Java, a LinkedHashMap is a popular data structure that combines the advantages of a doubly linked list with a hash map. The elements are retrieved in the same order as they were added since it preserves the sequence of insertion. When we need to iterate over the key-value pairs in a specified sequence, LinkedHashMaps are especially helpful. There are several methods accessible in situations where we want to print every mapping contained in a LinkedHashMap. In this article, we will examine two different methods for efficiently printing all LinkedHashMap's mappings in Java, each having its own benefits and sample ... Read More

Find Words which are Greater than given Length k using Stringstream

Avinash Gupta
Updated on 23-Aug-2023 21:30:42

226 Views

This is the problem based on stringstream class present in C++ “sstream” header file. Here, we have to find those strings whose lengths are greater than “k”. This task will be performed by using stringstream class. The concept is to partition the string and then iterate through the defined words. The value of length k has to be specified to obtain the words which are larger than k whereas the length of the words which are smaller than k will not be displayed in the output. In this article, we will understand how to find words which are greater than ... Read More

Length of Longest Common Subsequence Containing Vowels

Avinash Gupta
Updated on 23-Aug-2023 21:28:51

271 Views

In this problem, our task is to find the length of the longest possible subsequence present in two strings such that every letter of the subsequence must be a vowel. With the help of the recursive algorithm and iterative algorithm, the given problem statement can be solved. In English Alphabet, there exist five vowels named 'A', 'E', 'I', 'O', 'U'. Subsequence Vs. Substring: In Subsequence, we may take characters in a non-continuous way, but in Substring, we can take only continuous characters. Ex: In String “TutorialsPoint”: “tri” is a subsequence but not a substring. While “tor” is both subsequence ... Read More

Remove Duplicates from a String in O(1) Extra Space

Avinash Gupta
Updated on 23-Aug-2023 17:04:35

348 Views

In this problem, our task is to remove all the duplicate characters present in the string other than the first occurrence of every character. Also, it's required to solve the problem without using any extra space, and the Space complexity must be O(1). Various approaches are used in this article. The Boolean array is defined in one approach to determine the repetition of the characters where the index of Boolean array is mapped to each alphabet. In the second approach, the concept of the Bit manipulation is used to remove the repeated characters from the resultant string. Let's explore ... Read More

Sort Elements on the basis of the Number of Factors

Avinash Gupta
Updated on 23-Aug-2023 16:47:22

618 Views

In this problem, our task is to sort the array of integers based on several factors of numbers present in the array as a priority. The array is the best way to store similar types of elements in java. But if the number of factors becomes equal in any two numbers, then as a second priority, this algorithm sees numerical value. Factors are the numbers by which the given number is divisible entirely without leaving any remainder. This article uses various approaches to sort elements based on several factors. To show you some instances Instance-1 If Array = ... Read More

What does “!” mean in Java?

Priya Mishra
Updated on 23-Aug-2023 13:46:19

1K+ Views

Introduction Java supports eight types of operators; the “!” operator is one of them. In Java, an operator is a symbol used to execute operations. Operators are entities that can modify the values of operands. Java makes authoring, compiling, and debugging code simple. It is helpful in creating code that can be reused and applications that are modular. It was created with the goal of having a few implementation dependencies as feasible. Let’s discuss in detail about the Java operators, “!” operator and where to use it with some working examples. Java operators Operators in Java are symbols that are ... Read More

What is meant by object in Java?

Priya Mishra
Updated on 23-Aug-2023 13:40:23

162 Views

Introduction In real life, we can call tables, chairs, lamps, etc. objects as they have some attributes and functions. We can say that anything that has attributes or properties and some functionality like a lamp has a stand and a bulb and it can light up a room so it is an object. In Java also, we have objects and they have their own properties. Objects are basically the instance of the class and the class provides a blueprint for the creation of an object. Let’s have a brief discussion on objects and how to create an object in Java. ... Read More

What is the full form of Java?

Priya Mishra
Updated on 22-Jun-2024 19:36:03

4K+ Views

What is the Full Form of JAVA? The full form of Java is "Just Another Virtual Accelerator". Java is not an abbreviation but some programmers made a full form. Basically, Java doesn’t have any full form or special meaning. This full form is used jokingly by the programmers. J Just A Another V Virtual A Accelerator Related Links Some of the related topics, you may like to read: Overview of Java programming language Features of Java programming language

Previous 1 ... 5 6 7 8 9 ... 918 Next
Advertisements