Hi after a long time i am learning java , i have a confusion in calling the method without the help of the object.
public class VariablesInJava {
int instanceField=5;
static String staticField = "apple";
public void method() {
final String localVariable = "Initial Value";
System.out.println(localVariable);
}
public static void main(String args[]) {
VariablesInJava obj = new VariablesInJava();
System.out.println(obj.instanceField);
System.out.println(obj.staticField);
System.out.println(VariablesInJava.staticField);
System.out.println(new VariablesInJava().instanceField);
obj.method();
}
}
How can i call the method() without the help of object ?