Why the main method is public static void in Java?

If you have started learning Java and wondering why we have to type public static void for the main method, we’ve got you covered. In this post, we will discuss the significance of using public static void in front of the main method. In the main method, we use public static void because the JVM … Read more

Is Constructor Overriding Runtime Polymorphism in Java?

No, constructor overriding is not possible in Java, so whether it is runtime polymorphism or not is out of question. If you override a method of parent class in subclass and try to call that method using parent class reference variable, JVM decides which method to call at runtime. However, each class will have their … Read more

Instance Variable vs Reference Variable in Java

In this post we’ll discuss the differences between Instance Variable and Reference Variable in Java, understand them with an example. In a nutshell, a reference variable is any variable that can hold reference of an object and an instance variable is a primitive or non-primitive variable that is declared within a class. Instance Variable Reference … Read more

Substring Based on a Character in Java

String class provides us with powerful String processing methods, out of those, substring is one. In this example, we’ll look into examples on substring based on a given character in Java. Unfortunately, String class doesn’t provide us with an out of box substring method to get a substring based on a character, however you can … Read more

Private Final Variable in Java

A variable which is declared as private is not accessible outside of the class. That means you cannot access that private variable using a reference variable after instantiating the class. You can also declare a variable as private final in Java, then not only it will be accessible outside of the class, you will not … Read more