can anyone give me an explanation about static class in java
Thank u
A static class is one whose variables and methods can be called(invoked) without the class being instantiated,every other class has to be instantiated before its methods/variables can be invoked
hi thanks for your reply, can you please give me the clear picture of it, u mean to say that if u access any method or variables without the class being instantiated then that class is referred as static.
can u tell me that the main class is static or not
static in simple words means that we are not able to use instance variables(the class variabes)which don't have the word static in the main method or invoking other methods those don't have the word static also in the main method.
you will ask me why??
I will tell you that because the main method has the word static.
you will tell me I don't understand ,..ok fine look at this now, you can create an object in the same class you are working with in the main method to call the methods that don't have the word static by this statment ( object name.metthod name) you will notic that the program runs without any problem why because of the object you created also you can use in the main method the class variables that don't have the word static by (object name . class variable) why again because of the object. however the methods those don't have the word static they are able to use the variable class because they don't have the word static.so what does static mean? it means that no need to create the object as long as both the method and class variables share the same word static
also it means that no need to create object as long as the two methods are static(the first calls the other by mentioning the function name)
hope you understand .
please reply me if not.
thank you.
ya i got it, u mean to say that in static class , no need to instantiate an object until the variable and methods are declared as static
Thanks a million
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.