Alshifa Hasnain has Published 283 Articles

JavaScript - Finding the third maximum number in an array

Alshifa Hasnain

Alshifa Hasnain

Updated on 13-Dec-2024 21:50:14

883 Views

In this article, we will learn to find the third maximum unique number in an array of JavaScript, or the largest number if there are fewer than three unique values. We will be using three methods: a single-pass approach for efficiency, a sorting method to identify the number after removing ... Read More

Java Program to Save Decimal

Alshifa Hasnain

Alshifa Hasnain

Updated on 13-Dec-2024 21:49:28

874 Views

In this article, we will learn two ways to handle decimal values in Java. First, we will use the BigDecimal class to ensure precision when working with decimals. Then, we will use the DecimalFormat class to format decimal values. Both examples will show how to scale decimal values to three ... Read More

Java Program to get frequency of words with Lambda Expression

Alshifa Hasnain

Alshifa Hasnain

Updated on 13-Dec-2024 13:55:29

620 Views

In this article, we will learn how to calculate the frequency of words in a text using Java and Lambda Expressions. By leveraging concise syntax and functional programming techniques, we can efficiently process text data and determine word occurrences. This approach is particularly useful for applications like text analysis and ... Read More

Java Program for Pancake sorting

Alshifa Hasnain

Alshifa Hasnain

Updated on 13-Dec-2024 13:54:50

711 Views

In this article, we will learn pancake sorting which is a unique way to sort an array by flipping sections of it. The algorithm finds the largest unsorted element, flipping it to the front, and then flipping it to its correct position. Although not the fastest sorting method, it’s an ... Read More

JavaScript remove random item from array and then remove it from array until array is empty

Alshifa Hasnain

Alshifa Hasnain

Updated on 13-Dec-2024 13:53:44

2K+ Views

We are given an array of string/number literals. We are required to create a function removeRandom() that takes in the array, recursively removes one random item from it, and simultaneously prints it until the array contains items. This can be done by creating a random number using Math.random(), removing the ... Read More

Java Signature getInstance() method

Alshifa Hasnain

Alshifa Hasnain

Updated on 11-Dec-2024 19:33:16

2K+ Views

In this article, we will learn about the Signature.getInstance() method, how it works, and examples that demonstrate its usage. A signature object that can implement the required signature algorithm can be obtained using the method getInstance(). The Signature.getInstance() method in Java is a crucial component of the Java Cryptography Architecture ... Read More

Java Connection setSavepoint() method with example

Alshifa Hasnain

Alshifa Hasnain

Updated on 11-Dec-2024 11:31:31

935 Views

When working with databases in Java, there are scenarios where you might want to perform complex transactions involving multiple steps. To maintain control and flexibility during such operations, Savepoints come into play. The setSavepoint() method in the java.sql.Connection interface allows you to create a savepoint within a transaction, providing a ... Read More

JavaScript get row count of an HTML table

Alshifa Hasnain

Alshifa Hasnain

Updated on 06-Dec-2024 21:39:08

4K+ Views

Tables are a common way to organize and display data in HTML. If you're working with tables dynamically in JavaScript, you might need to count the rows in an HTML table for various purposes, such as validation, manipulation, or displaying statistics. In this article, we will demonstrate how to retrieve ... Read More

Java program to divide a string in \\'N\\' equal parts

Alshifa Hasnain

Alshifa Hasnain

Updated on 23-Oct-2024 17:32:12

825 Views

In this article, we will understand how to divide a string into 'N' equal parts using Java. If the string's length is divisible by N, the string will be split evenly into N parts; otherwise, a message will be displayed indicating that the string cannot be divided into N equal ... Read More

Java application to insert null value into a MySQL database

Alshifa Hasnain

Alshifa Hasnain

Updated on 10-Oct-2024 11:36:15

1K+ Views

In this program, we will connect to a MySQL database and insert a null value into a table using Java's JDBC API. We will use the PreparedStatement class along with the setNull() method to achieve this. After the value is inserted, you can check the table to see how the ... Read More

Advertisements