Instance Main and Non-Instance Main method in one class example

In this post under Java language, I will show with example how Java runs a program which has two main methods. Here two main methods means one traditional public static void main method as shown below public static void main(String[] args) { } and another being the new main method as shown below void main()…… Continue reading Instance Main and Non-Instance Main method in one class example

Text Block With Indentation

In this post under Java Core, I will show you with example how indentation is calculated in Text Block. Below is the main class with three variety of text block. Example3 package core.string; public class Example3 { public static void main(String[] args) { String textBlock1 = """ <html> <head> <title>TextBlock1<title> </head> <body>Body of TextBlock1</body> </html>…… Continue reading Text Block With Indentation

Using Comparable with multiple fields

In this post under Java Collections, I will show an example of how to use Comparable interface when we need to sort collections on multiple fields For our example, we will sort a collections of employee objects. I need to sort the collections of employee objects in ascending order first using there name and then…… Continue reading Using Comparable with multiple fields

Pattern matching with instanceof

Hi all, in this post under Java pattern matching section, I will introduce you to pattern matching and how to use it with instanceof operator. Please don’t confuse java pattern matching with regex pattern matching Regex pattern matching checks whether a given text matches a text pattern and may optionally extract parts of the text.…… Continue reading Pattern matching with instanceof