- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2616 Articles for Java
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
76 Views
In this problem, we will check if it is possible to divide the given numeric string into two disjoint subsequences such that sum(sub1) * sum(sub2) becomes odd. We need to divide the string into two subsequences such that the sum of the digits of both becomes odd to get the odd multiplication result. Problem statement − We have given a string num_string containing the numeric characters. We need to check whether we can divide the string into two subsequences such that the multiplication of the sum of both subsequences becomes odd. Also, it is given that every character of the ... Read More
![Avinash Gupta](https://www.tutorialspoint.com/assets/profiles/701626/profile/60_691552-1692786372.jpg)
172 Views
In this article, we are going to find the different ways to find the frequency of numbers present in an array []. These methods are very useful in doing competitive programming for different problems for different cases. Sometimes, calculating the frequency of elements whether it is numbers or alphabets presented in the array is a complicated task. Various algorithms like Searching, array, divide and conquer can be used to find the repeated elements defined in the array. Note- Take an integer array. Let's explore the article, to know how it can be solved by using Java programming ... Read More
![Vanshika Sood](https://www.tutorialspoint.com/assets/profiles/641407/profile/60_757993-1681820687.jpeg)
750 Views
The objective of this article is to determine the smallest string that is a multiple of both given strings. An interesting observation to note is that for two given strings s and t, the string s is a multiple of t if and only if s can be formed by repeating t one or more times. We have to find the smallest such string. Problem Statement Given two non-empty strings, s1 and s2, with lengths n and m respectively, the objective is to determine the smallest string that is a multiple of both s1 and s2. A ... Read More
![Adeeba Khan](https://www.tutorialspoint.com/assets/profiles/687638/profile/60_803497-1690546101.jpg)
10K+ Views
When dealing with Java terminal apps, individuals may frequently want to print colored text to improve the output's aesthetic appeal and readability. ANSI escape codes can be used to generate colored text instead of the monochrome output that Java's default terminal generally produces. When printed to the console, ANSI escape codes are unique sets of characters that alter the text's appearance by altering its color, style, or background. In this article, we'll look at how to print colored text in the Java console using ANSI escape codes. We'll go over two examples, one with colored text only and the other ... Read More
![Adeeba Khan](https://www.tutorialspoint.com/assets/profiles/687638/profile/60_803497-1690546101.jpg)
2K+ Views
The task of printing an array's elements in Java is one that programmers come upon regularly. Having a simple and effective technique for printing arrays is crucial, whether you want to display the array contents for debugging purposes, present them to the user in a prepared manner, or analyze the data within the array. While utilizing a loop is the most common and conventional strategy, there may be times when you need to look into other options to do the same objective. To provide you with a new viewpoint on how to handle array printing chores, this article seeks to ... Read More
![Adeeba Khan](https://www.tutorialspoint.com/assets/profiles/687638/profile/60_803497-1690546101.jpg)
679 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
![Adeeba Khan](https://www.tutorialspoint.com/assets/profiles/687638/profile/60_803497-1690546101.jpg)
2K+ 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
![Adeeba Khan](https://www.tutorialspoint.com/assets/profiles/687638/profile/60_803497-1690546101.jpg)
272 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
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
76 Views
In this problem, we need to change the minimum characters in the given string to make its left and right rotations the same. In the string, we can observe that we can only make the left and right rotations of the string same if the string has an odd length and all characters are same, or the string has an even length and characters at even and odd indexes the same. For example, abab – Left and right rotation of the string is baba and baba. aaa – Left and right rotation of the stirng is aaa and aaa. ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
76 Views
In this problem, we will write Java code to find the maximum sum of consecutive zeros at the start and end of any string rotation. First, we will use a naïve approach to solve the problem, which generates all rotations of the binary string and counts the starting and ending consecutive zeros. After that, we will learn an optimized algorithm that counts the maximum consecutive zeros. Problem statement – Here, we have a string of size N containing only 0 and 1 characters. We need to find the maximum sum of consecutive zeros at the start and end of any ... Read More