java

java

Java program to check if a user input number is strong or not

Java program to check if a user input number is strong or not. A number is called a strong number if the sum of all factorials of its digits is equal to the number itself.

Read
java

How to get the last element of a stream in Java

Learn how to get the last element of a Java stream. We will learn two different ways to find the last element of a stream with examples.

Read
java

How to get a random line from a file in Java

Java program to get a random line from a file in Java. This program will take the path of the file and print a random line. You will learn how to use Random module to create a random number.

Read
java

Java program to check if the first character of a string is number/digit

Java program to check if the first character of a string is a number or digit. We will learn to solve this by using two different ways - using charAt and isDigit and by using regex.

Read
java

Java stream mapToInt explanation with examples

Java stream mapToInt is used to get one integer stream from a different stream by applying a functing to all members of a stream. This post will show you how to use mapToInt with example.

Read
java

Difference between findAny and findFirst of Java Stream API

findAny and findFirst methods are defined in Java Stream API. This post will show you the difference between these methods with example.

Read
java

3 different ways to copy a string in Java

Learn how to copy a string in Java in three different ways. We will learn how to copy a string using direct assignment, using StringBuffer and using String.copyValueOf.

Read
java

What is static method shadowing in Java

Method shadowing comes up when we have methods with same name and parameters in both super class and sub class. This post will show you what is static method shadowing works in java.

Read
java

How Java Collections.rotate method works

Learn how java.util.Collections work with example. rotate method is used to rotate the contents of a list. It takes the list and distance as parameters.

Read
java

2 different ways to swap two elements in an ArrayList in Java

This post will show you two different ways to swap two elements in an ArrayList in Java. The program will take the index positions from the user and swap the values in the ArrayList.

Read