Karthikeya Boyini has Published 2193 Articles

Java program to get random letters

karthikeya Boyini

karthikeya Boyini

Updated on 05-Sep-2024 11:24:47

2K+ Views

In this article, we will learn to write a program in Java to get the random letters in both lowercase and uppercase. We will be using Random class from java.util package.The program will first create random lowercase letters by selecting them from the alphabet, and then it will generate random ... Read More

Java program to get milliseconds between dates

karthikeya Boyini

karthikeya Boyini

Updated on 05-Sep-2024 11:22:45

2K+ Views

In this article, we will learn to get milliseconds between dates in Java. We will be using the LocalDateTime class from java.time package and ChronoUnit.MILLIS of java.time.temporal package. ChronoUnit is an enum that is part of Java date and time API which represents a unit of time that is days, hours, minutes etc. ... Read More

Java program to sort long Array

karthikeya Boyini

karthikeya Boyini

Updated on 30-Aug-2024 11:43:14

2K+ Views

In this article, we will sort a long array in Java. We will be using the Arrays.sort() method of Arrays class which is present in java.util package. It will helps us to organize data in ascending order, making it easier to use. We'll start with an unsorted array, display it, sort ... Read More

Java program to calculate distance light travels

karthikeya Boyini

karthikeya Boyini

Updated on 27-Aug-2024 18:48:19

2K+ Views

In this article, we will demonstrate how to calculate the distance light travels in one year using Java. We will use the Demo class and the main method to perform this calculation. Speed of light: 186000Days = 365dist = speed * seconds Problem Statement Write a Java program to calculate ... Read More

Java program to check if a file or directory is readable

karthikeya Boyini

karthikeya Boyini

Updated on 21-Aug-2024 00:09:20

2K+ Views

In this article, we will learn to check if a file or directory is readable. We will use the Java File canRead() method of the java.io package to check if a file or directory is readable in Java. This method returns true if the file specified by the abstract path ... Read More

Java program to set a range for displaying substring

karthikeya Boyini

karthikeya Boyini

Updated on 19-Aug-2024 18:33:51

2K+ Views

In this article, we'll learn how to extract a specific range of characters from a string in Java using the substring() method. The substring(int beginIndex, int endIndex) method gets a part of a string from the beginIndex to just before the endIndex. Problem Statement Given a string, extract a substring ... Read More

Basic calculator program using Java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Aug-2024 18:30:26

23K+ Views

In this article, we will learn to create a basic calculator using Java. With a basic calculator, we can add, subtract, multiply, or divide two numbers. This is done using a switch case. A program that demonstrates this is given as follows − Problem Statement Write a program in Java to ... Read More

Java program to create a new list with values from existing list with Lambda Expressions

karthikeya Boyini

karthikeya Boyini

Updated on 12-Aug-2024 23:13:48

3K+ Views

In this article, we will demonstrate how to create a new list of employee names from an existing list of Employee objects using Lambda Expressions. We will utilize Java’s Stream API to efficiently map the employee data and collect it into a new list. Lambda Expressions: Lambda expressions simplify functional ... Read More

Java program to count the number of consonants in a given sentence

karthikeya Boyini

karthikeya Boyini

Updated on 08-Aug-2024 17:37:15

10K+ Views

In this article, we will count the number of consonants in a given sentence using Java to achieve this, we will use the Scanner class for user input and a for loop to iterate through each character in the sentence. By comparing each character with the vowels a, e, i, ... Read More

Java program to check for URL in a string

karthikeya Boyini

karthikeya Boyini

Updated on 07-Aug-2024 21:46:44

2K+ Views

In general, to check if a given string is a valid URL(Uniform Resource Locator), we will create a method that tries to form a URL object and catches any exceptions to determine if the string is a valid URL. By using Java's URL class and exception handling, we will demonstrate ... Read More

Previous 1 ... 3 4 5 6 7 ... 220 Next
Advertisements