I have a question. When do you use the static method? I made the getters and setters methods. I want to make these methods callable only when an object is created. But do I have to use a static method to do this?
java static-methods
Obj x = new Obj();
x.someMethod
Obj.someMethod
Which is the static call method?
To make the object callable only when it is created, you can just create it in the normal method.
Static methods are literally methods that already exist in memory when a class is defined. Therefore, the method exists and is callable even if the object of the class is not created. Instead, it does not access the object's variables. Because the variable of an object exists only when the object is created.
© 2024 OneMinuteCode. All rights reserved.