Find Maximum Odd Number in Array Using Stream and Filter in Java

Shiva Keerthi
Updated on 25-Jul-2024 19:32:19

2K+ Views

In this section, we are going to write a Java program to find maximum odd number in an Array using Stream and Filter. Odd numbers are the numbers which cannot be divided by 2 or these numbers give remainder as 1 when they are divided by 2. In other terms which can be written in the form of 2n+1. We will find the maximum odd number in the array. Problem Statement Write a program in Java to find maximum odd number in array using stream and filter − Input array = {1, 7, 2, 3, 9, ... Read More

Save a String to a File in Java

Rudradev Das
Updated on 24-Jul-2024 21:54:31

3K+ Views

String, the series of characters, used in Java programming enable to save memory consumption and boost the performance. We can save a string to a file using Java program can be initiated in multiple ways and has been introduced in Java version 11. Four parameters can be used to save a string to a file using Java. They are the file path, character sequence, charset, and options. File path and character sequence, these two are the most important and mandatory for this approach to write into a file. This technique encodes the characters as the content, and it returns the ... Read More

Sort an Array in Case-Insensitive Order in Java

George John
Updated on 24-Jul-2024 21:53:28

3K+ Views

An array can be sorted in case-insensitive order using the java.util.Arrays.sort() method. Also the java.text.Collator class is required as Collator.getInstance() is used to obtain the Collator object for the required locale. Problem Statement  Write a program in Java to sort an array of strings in a case-insensitive order. A program that demonstrates this is given as follows − Input The unsorted array is: [apple, mango, Banana, Melon, orange] Output The sorted array in case-insensitive order is: [apple, Banana, mango, Melon, orange] Steps to sort an array in case-insensitive order Below are the steps to sort an array in case-insensitive ... Read More

Replace a Word with Asterisks in a Sentence in Java

AmitDiwan
Updated on 24-Jul-2024 21:48:46

3K+ Views

In this article, we will learn how to replace a specific word in a sentence with asterisks using Java. This technique can be useful for obscuring certain words in a text for privacy or censorship purposes. Problem Statement Develop a program in Java that takes a sentence and a word to be censored as input, then outputs the sentence with the specified word replaced by asterisks, while preserving the original format of the sentence. Input This is a sample only, the sky is blue, water is transparent Output This is a ****** only, the sky is blue, water is transparent ... Read More

Reverse an Array in Groups of Given Size in Java

Samual Sam
Updated on 24-Jul-2024 16:39:32

3K+ Views

An array can be reversed in groups of a given size by reversing the subarrays of the required size. In the given article, the program demonstrates a technique for reversing an array in groups of a specified size. This technique is useful in various computational tasks and algorithm design. The program takes an array and a group size as input and reverses the array in groups of that size. The original and modified arrays are then printed to the console. Problem Statement Write a Java program to reverse an array in groups of a given size. An example of ... Read More

Difference Between Gradle and Maven

Shirjeel Yunus
Updated on 24-Jul-2024 11:47:15

243 Views

Gradle is a tool which is used in Java development. One of its main jobs is to create automation tools. Maven is used as an alternative to Gradle but it is older and helps in building the tools which are best for a project. Developers can make a choice between them on the basis of their requirements for a project. In this article, we will discuss the difference between Gradle and Maven. What is Gradle? Gradle is an open-source automation system which uses domain-specific language called Groovy. This is a programming language that uses XML for the configuration of a ... Read More

Add Multiple Elements in the Same Table

Vikash Kumar
Updated on 24-Jul-2024 11:45:41

528 Views

In HTML tables, the element is used to group and organize the content of the table into sections. It is especially useful when working with large tables. It helps to manage and style the data effectively. While a table contains one , you can have multiple elements within the same table to structure data into different sections or categories. Why to use Multiple Elements? Grouping Data: Multiple elements allow you to group related rows of data separately within the same table. Styling: You can apply ... Read More

Find Length of Longest Substring Without Repeating Characters in Java

Prabhdeep Singh
Updated on 24-Jul-2024 11:43:39

2K+ Views

In Java, substrings are part of the string which contains the continuous character of the string of any length from 1 to complete string. We are given a string and we have to find the length of the largest substring from the given string that only contains the unique characters. We will see three types of methods: finding every substring, sliding windows, and two-pointers. Problem Statement Given a string, write a Java program to find length of the longest substring without repeating characters − Input thisisthegivenstring Output The length of the longest substring that contains only unique characters is: ... Read More

Difference Between HAVING Clause and GROUP BY Clause

Shirjeel Yunus
Updated on 24-Jul-2024 11:42:18

1K+ Views

SQL is a language which consists of different types of clauses in the Select statement like Where Group by Having Order by These clauses are used to retrieve values, sort them, group them, and do a lot of other things. In this article, we will discuss the difference between having clause and group by clause. What is Having Clause? The Having clause is used to filter groups of rows based on a condition, which often includes the aggregate functions. It comes after the GROUP BY clause in a SQL query. Unlike the WHERE clause, which filters rows before ... Read More

Difference Between Propositional Logic and Predicate Logic

Shirjeel Yunus
Updated on 24-Jul-2024 11:38:57

8K+ Views

Logical reasoning is one of the main subjects of computer science and mathematics. This reasoning helps in making the decisions of whether different types of mathematical arguments are correct or not. It can be divided into propositional logic and predicate logic. Both of these topics are required for different subjects like mathematics, philosophy, computer science, etc. These concepts are very complex and are used in creating various types of arguments. Let us discuss the difference between propositional logic and predicate logic. What is Propositional Logic? A proposition consists of a truth value which should not be ambiguous to the two ... Read More

Advertisements