Java Articles

Page 170 of 450

Java Program to convert integer to String with Map

Alshifa Hasnain
Alshifa Hasnain
Updated on 07-Jan-2025 825 Views

In this article, we will learn to convert integers to String with Map in Java. The Stream API has become an essential tool for processing collections of data in a more declarative and readable way. Instead of using traditional loops, streams allow developers to filter, map, and perform other operations on data with minimal code Problem Statement Given an integer, we need to convert it to its string representation where the integer is treated as a character (e.g., 5 becomes "5", 10 becomes "10"). We'll use a Map to define the integer-to-string mappings and retrieve the string equivalent for a ...

Read More

Java Program for Reversal algorithm for right rotation of an array

Shriansh Kumar
Shriansh Kumar
Updated on 07-Jan-2025 394 Views

An array is a linear data structure that stores a group of elements with similar datatypes, in a sequential order. Once we create an array, we can’t change its size, i.e., it can store a fixed number of elements. In this article, we will learn how to write a Java program where we create an array and perform the right rotation using the reversal algorithm. Right Rotation of an Array Let’s understand the term right rotation in the context of an array. In the right rotation of an array, we simply shift the elements of the array to our right till the specified number ...

Read More

Java Integer compare() method

Alshifa Hasnain
Alshifa Hasnain
Updated on 06-Jan-2025 3K+ Views

Integer compare() Method The compare() method in the Integer class is a part of the Java interface and is used to compare two integers. It provides a way to compare two Integer objects or primitive int values and determine their relative ordering. This method is particularly useful when sorting or working with collections that involve integer values. Syntax public static int compare(int x, int y);Where − x: The first integer to be compared. y: The second integer to be compared. Return Value The compare() method returns an integer value that ...

Read More

Java DatabaseMetaData getMaxBinaryLiteralLength() method with example.

Smita Kapse
Smita Kapse
Updated on 02-Jan-2025 185 Views

In this article, we will learn about the getMaxBinaryLiteralLength() method of the DatabaseMetaData interface in JDBC.  getMaxBinaryLiteralLength() method The getMaxBinaryLiteralLength() method of the DatabaseMetaData interface is used to find out the maximum number of characters (hex) that the underlying database allows for a binary literal. This method returns an integer value, representing the maximum length of a binary literal. If this value is 0 it indicates that there is no limit or, the limit is unknown. Steps to get the DatabaseMetaData object The following are the steps to get the DatabaseMetaData object − ...

Read More

Java DatabaseMetaData getDatabaseMinorVersion() method with example

Rishi Raj
Rishi Raj
Updated on 02-Jan-2025 172 Views

In this article, we will learn how to use the getDatabaseMinorVersion() method of the DatabaseMetaData interface in Java to retrieve the minor version of the underlying database. This method helps check the version details of the connected database. What is DatabaseMetaData?The DatabaseMetaData is an interface that provides methods to retrieve metadata about a database, such as the database product name, version, driver name, the total number of tables, views, and more. To get the DatabaseMetaData object, use the getMetaData() method of the Connection interface.Syntax: public DatabaseMetaData getMetaData() throws SQLException; ...

Read More

Java Program to display Frame after some seconds

karthikeya Boyini
karthikeya Boyini
Updated on 02-Jan-2025 501 Views

In this article, we will learn how to display a frame after a few seconds in Java using the Timer class. This example shows how to delay the visibility of a frame by 2 seconds using Swing. Timer() class The Timer class is used to schedule tasks that execute after a specific time interval or repeatedly at regular intervals. It allows tasks to be run by a thread that handles the scheduling and execution. Each task can be set to execute either once or repeatedly at fixed intervals. The execution of all tasks is managed by a background thread associated ...

Read More

Java Program to Delete a Node From the Ending of the Circular Linked List

Rushi Javiya
Rushi Javiya
Updated on 02-Jan-2025 305 Views

In this article, we will learn the remove the last node of the circular linked list in Java. We set Null to the next pointer of the second-last node to remove the last node from the regular linked list, but in the circular linked list, we need to set the root node to the next pointer of the second-last node. Steps to delete a node from the ending of the circular linked list We will find the second-last node of the circular linked list. While traversing the linked list, we can check whether the next pointer of the current node ...

Read More

Java Program to set the extent in JSlider

Arjun Thakur
Arjun Thakur
Updated on 02-Jan-2025 339 Views

In this article, we will learn how to set the extent of a JSlider using Java Swing. The extent defines the size of the range that the slider's knob can move within, restricting its movement past a certain point. JSlider JSlider is a component in Java Swing that provides a visual way to select a value by sliding a knob within a specified range. The setExtent() method in JSlider sets the size of the range that the knob covers, which controls how far it can move. setExtent() method The setExtent() method in Java is used to: ...

Read More

Java program to convert a Map to a read only map

karthikeya Boyini
karthikeya Boyini
Updated on 31-Dec-2024 731 Views

A read-only map in Java is a type of Map that cannot be modified after it has been created. This means that once the map has been set to be read-only, we cannot add, remove, or update any of the key-value pairs.Converting a Map to a read only map We can convert a mutable map to an immutable map, a read-only map using the Collections.unmodifiableMap() method. This method provides a way to make sure that the map cannot be modified once it has been wrapped in this method. Following are the steps to convert a Map to a read-only map ...

Read More

Java Program to mark the current position in this input stream

Alshifa Hasnain
Alshifa Hasnain
Updated on 30-Dec-2024 604 Views

In this article, we will learn to mark and reset the current position in a file input stream in Java. Marking the current position in an input stream is a crucial functionality provided by Java’s InputStream class. It enables developers to reset the stream to a previously marked position, facilitating efficient data handling, especially in scenarios like re-reading or backtracking within a file. Key Concepts Following are the key concepts we need to know to mark the current position in this input stream − InputStream Class: The InputStream class is an abstract class that represents ...

Read More
Showing 1691–1700 of 4,496 articles
« Prev 1 168 169 170 171 172 450 Next »
Advertisements