Alshifa Hasnain

Alshifa Hasnain

Converting Code to Clarity

About

A professional technical content writer with Java programming skills. I have a desire to write informative and detailed Java articles for both beginner and professional developers. Having a strong background in HTML, CSS, JavaScript, Java, JDBC, JSP, Spring, and Hibernate.

221 Articles Published

Articles by Alshifa Hasnain

Page 18 of 23

Java Program to Sort ArrayList of Custom Objects by Property

Alshifa Hasnain
Alshifa Hasnain
Updated on 22-Jan-2025 760 Views

In this article, we will learn to sort ArrayList of custom objects by property in Java. The ArrayList class extends AbstractList and implements the List interface. ArrayList supports dynamic arrays that can grow as needed. Problem Statement ArrayList is created with an initial size. When this size is exceeded, the collection is automatically enlarged. When objects are removed, the array may be shrunk. Below is a demonstration of the same − Input − The list is defined as Java Scala Python Mysql Output  − The list after sorting values: Java Mysql Python Scala ...

Read More

Java program to convert millisecond to readable string

Alshifa Hasnain
Alshifa Hasnain
Updated on 22-Jan-2025 957 Views

In this article, we will learn to convert milliseconds to readable strings in Java. Converting milliseconds into a human-readable format such as hours, minutes, seconds, and milliseconds is a common programming task, especially in time-sensitive applications. Problem Statement The challenge is to convert a given time in milliseconds into a readable string that shows hours, minutes, seconds, and remaining milliseconds. Input long millis = 5000000; Output  Hours = 1 Minutes = 23 Seconds = 20Milliseconds = 0 1 hr(s) 23 min(s) 20 sec(s) 0 ms Approaches to convert millisecond to readable string Following are the two different approaches to converting milliseconds ...

Read More

Java program to generate n distinct random numbers

Alshifa Hasnain
Alshifa Hasnain
Updated on 22-Jan-2025 1K+ Views

In this article, we will learn to generate n distinct random numbers within a specified range, ensuring that no number is repeated in Java. Generating random numbers is a common problem in various applications such as simulations, games, and testing. Problem Statement In this problem, we are given a number n, and we need to generate n unique random numbers within a defined range, ensuring that no number is repeated. The range can be specified by the user, or it can be a default range based on the problem's requirements. Input int n = 10; Output [4, 6, 9, 1, ...

Read More

JavaScript Array Ranking

Alshifa Hasnain
Alshifa Hasnain
Updated on 22-Jan-2025 878 Views

In this article, we will learn to rank elements in arrays using JavaScript. Ranking elements in an array is common in various applications, such as sorting scores, evaluating performance, or analyzing data. What is Array Ranking? Array ranking involves assigning a rank to each element of an array based on its value, where the largest value gets the highest rank and the smallest value gets the lowest rank. This ranking can be extended to multiple arrays to analyze and compare data across different datasets. Problem Statement We are given multiple arrays of numbers. The task is to compute ranks for ...

Read More

JavaScript: How to return True if the focus is on the browser tab page?

Alshifa Hasnain
Alshifa Hasnain
Updated on 22-Jan-2025 2K+ Views

In this article, we will learn to check if the browser tab page is focused and under use or not in JavaScript. This is mainly required to record the user’s inactivity time on the app and then take any action upon it if required. Use Cases for Monitoring Browser Tab Focus Following are the use cases for monitoring browser tab focus and user inactivity − Prevent sending the network request if the page is not being used by the user as this would reduce the traffic on the server. This would ...

Read More

Java program to reverse an array

Alshifa Hasnain
Alshifa Hasnain
Updated on 20-Jan-2025 2K+ Views

In this article, we will learn to reverse an array in Java. Reversing an array is a classic problem that helps understand essential concepts like data structures and in-place manipulation. This operation is commonly required in programming tasks, such as data transformations, algorithm implementations, and solving logical problems. Problem Statement Reversing an array involves rearranging its elements so that the first element becomes the last, the second becomes the second-to-last, and so on. Input int[] myArray = {23, 93, 56, 92, 39}; Output {39, 92, 56, 93, 23} Different Approaches Following are the two different approaches to reverse an array ...

Read More

Create array from JSON object JavaScript

Alshifa Hasnain
Alshifa Hasnain
Updated on 20-Jan-2025 1K+ Views

In this article, we will learn to create an array from JSON data in JavaScript. JSON is a widely used format for storing and exchanging data. A common use case involves extracting specific data from a JSON object or array and converting it into a separate array for further processing. What is JSON Data? JSON (JavaScript Object Notation) is a lightweight data format commonly used to store and exchange data between a server and a client. It represents data as key-value pairs and is easy for both humans and machines to read and write. In JavaScript, JSON objects or arrays can be ...

Read More

Java ResultSet isAfterLast() Method with Examples

Alshifa Hasnain
Alshifa Hasnain
Updated on 20-Jan-2025 1K+ Views

The ResultSet interface in Java is used to retrieve data from a database in a tabular form. The isAfterLast() method is one of the navigation methods in the ResultSet that helps in checking the position of the cursor. Specifically, isAfterLast() checks whether the cursor is positioned after the last row of the result set. Method Definition The isAfterLast() method of the ResultSet interface is used to determine whether the cursor is after the end of the ResultSet.This method returns a boolean this value is true, if the cursor is after the end of the ResultSet else, it returns false. ...

Read More

JavaScript Quicksort Recursive

Alshifa Hasnain
Alshifa Hasnain
Updated on 17-Jan-2025 1K+ Views

In this article, we will learn to implement Quicksort recursively in JavaScript. Quicksort is one of the most efficient and widely used sorting algorithms, known for its divide-and-conquer approach. What is Quicksort? Quicksort is a divide-and-conquer sorting algorithm that sorts an array by selecting a pivot element and partitioning the array into two subarrays: elements smaller than the pivot and elements greater than or equal to the pivot. It then recursively sorts the subarrays.  Algorithm Quicksort follows the below steps − Step 1 − Make any element the pivot (preferably first or last, ...

Read More

Java Program to append a row to a JTable in Java Swing

Alshifa Hasnain
Alshifa Hasnain
Updated on 17-Jan-2025 1K+ Views

Adding rows dynamically to a JTable is a common task in Java Swing when working with user interfaces that involve tabular data. This article walks you through creating a Java Swing application that appends a new row to a JTable when the user inputs data and clicks a button. What is JTable? A JTable is a powerful Swing component for displaying and editing tabular data. By using a DefaultTableModel, we can manage the table's data dynamically, including adding or removing rows. This makes it an excellent choice for applications requiring user interaction. Approach Following are the steps to append a row ...

Read More
Showing 171–180 of 221 articles
« Prev 1 16 17 18 19 20 23 Next »
Advertisements