Know the Details of the Current Method Being Executed
You might be interested to know where the current code flow is. The getMethodName() method in the getStackTrace(), if used as illustrated below, is really helpful. As always, specific use
You might be interested to know where the current code flow is. The getMethodName() method in the getStackTrace(), if used as illustrated below, is really helpful. As always, specific use
Learn how to use the findAny method in java.util.Stream. This returns an Optional describing an element, or an empty Optional if Stream is empty. Also, remember that the same stream
In Java, characters as  cannot appear in a regular expression without being escaped. For this, rely on the Pattern.quote() method as in the following example: public static boolean contains(String t1, String
import java.util.*;public class FindJavaVersion{ public static void main(String args[]) { FindJavaVersion findJavaVersion = new FindJavaVersion(); findJavaVersion.printDetails(); } private void printDetails() { Properties systemProperties = System.getProperties(); System.out.println(“Java version: ” + systemProperties.get(“java.version”));
A typical mechanism of converting to a string, traversing and counting has a lot of processing to complete. Instead, the code below shows a combination of methods in Math package
Getting to know the available drive types in the system is essential for certain activities in Java. The following code snippet lists the available drive types in the system: */import
Starting with JDK 12, the “switch” statement is extended so that it can be used as either a statement or an expression. A sample: switch (day) { case MONDAY, FRIDAY,
To create a new date, you will need a Calendar instance and then you can set the Calendar instance to the date you need. Calendar calendar = Calendar.getInstance(); The line
Proper formatting of output is essential. There are times when the details presented are not formatted. The code snippet below displays details in a formatted manner that is a better