by BehindJava
Java Static keyword real time example in Java
Java Static keyword real time example in Java
In this tutorial, we are going to learn about java static keyword static methods are generally used to perform an operation that is not dependent upon instance creation.
If there is a code that is supposed to be shared across all instances of that class, then write that code in a static method and They are state of class not the state of the object. Example: let’s take a database connection class that must be shared across the application.
Sample Code Snippet:
public class DatabaseConfig {
static void databaseConn()
{
//Databse configurations System.out.println("static method called");
}
}
Please refer to this for reference https://www.behindjava.com/java-AES256-key/