Karthikeya Boyini has Published 2193 Articles

Java program to access character of a string

karthikeya Boyini

karthikeya Boyini

Updated on 11-Nov-2024 19:16:55

35K+ Views

In this article, we will access a specific character from a string by using the charAt() method in Java. The program will demonstrate how to locate and display a character at a specified position within a string. Problem Statement We have a string, and we need to retrieve the ... Read More

Java program to close this input stream and release any system resources associated with the stream

karthikeya Boyini

karthikeya Boyini

Updated on 11-Nov-2024 19:15:09

222 Views

This Java article discusses the InputStream.close() function to close the input stream and free up system resources. The method java.io.InputStream.close() is used to close this input stream and release any system resources associated with the stream. This method requires no parameters and returns no value. Also, the IOException is thrown ... Read More

Java program to remove a key from a HashMap

karthikeya Boyini

karthikeya Boyini

Updated on 07-Nov-2024 01:07:01

692 Views

In this article, we will learn how to remove a specific key from a HashMap in Java. By doing this, we can dynamically update the contents of the map, which is helpful in many data manipulation scenarios. We will demonstrate two different approaches: one that uses the straightforward remove() ... Read More

Java program to generate a random number from an array

karthikeya Boyini

karthikeya Boyini

Updated on 04-Nov-2024 18:44:53

5K+ Views

In this article, we will learn how to generate a random number from an array of integers in Java by using Random class. The Random class provides methods to generate random numbers, and we will use the nextInt(int bound) method to get a random index within the bounds of our ... Read More

Java program to find maximum of three numbers

karthikeya Boyini

karthikeya Boyini

Updated on 04-Nov-2024 18:42:13

30K+ Views

In this article, we will learn how to find the maximum among three numbers using an if-else statement in Java. The if-else construct allows us to evaluate conditions and execute different blocks of code based on whether the conditions are true or false. We will check the values of three ... Read More

Java program to put value to a Properties list

karthikeya Boyini

karthikeya Boyini

Updated on 30-Oct-2024 18:44:44

391 Views

In this article, we will learn how to use the Properties class in Java to store and display key-value pairs. The Properties class is useful for handling configuration settings or storing data in a structured way, where both keys and values are strings. By using the put() method, we can ... Read More

Java program to merge duplicates of a List with TreeSet

karthikeya Boyini

karthikeya Boyini

Updated on 30-Oct-2024 18:36:14

574 Views

In this article, we will learn to merge duplicate elements from a List in Java by using a TreeSet. This program will take a List of strings containing duplicate values, transfer the elements into a TreeSet, and display the unique, sorted elements. Using a TreeSet is ideal here because it ... Read More

Java program to find the LCM of two numbers

karthikeya Boyini

karthikeya Boyini

Updated on 23-Oct-2024 17:35:36

8K+ Views

In this article, we will learn to find the LCM of two numbers using Java. L.C.M. or Least Common Multiple of two values is the smallest positive value which is the multiple of both values. For example, multiples of 3 and 4 are: 3 → 3, 6, 9, 12, 15 ... Read More

Java program to get minutes between two time instants

karthikeya Boyini

karthikeya Boyini

Updated on 18-Oct-2024 11:58:13

906 Views

In this article, we will calculate the number of minutes between two-time instants using Java. This will be done by using the Instant and Duration classes from the java.time package. We'll create two instances of time, add specific hours and minutes to one of them, and then compute the difference ... Read More

Java program to add long integers and check for overflow

karthikeya Boyini

karthikeya Boyini

Updated on 16-Oct-2024 16:29:42

1K+ Views

In this article, we will add two long integers in Java and check if the sum causes an overflow, which happens when the result exceeds the maximum value that a long data type can hold,  defined by the Long class as Long.MAX_VALUE. If the sum goes beyond this limit, an ... Read More

Advertisements