943,915 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1534
  • Java RSS
Sep 26th, 2007
0

static

Expand Post »
can anyone give me an explanation about static class in java

Thank u
Similar Threads
Reputation Points: 37
Solved Threads: 0
Newbie Poster
tinamary is offline Offline
16 posts
since May 2007
Sep 26th, 2007
0

Re: static

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
spaceman is offline Offline
1 posts
since Sep 2007
Sep 27th, 2007
0

Re: static

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
Reputation Points: 37
Solved Threads: 0
Newbie Poster
tinamary is offline Offline
16 posts
since May 2007
Sep 27th, 2007
0

Re: static

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
alsoumhi is offline Offline
66 posts
since Aug 2007
Sep 27th, 2007
0

Re: static

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
Reputation Points: 37
Solved Threads: 0
Newbie Poster
tinamary is offline Offline
16 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Non-Static method cannot be referanced from a Static context
Next Thread in Java Forum Timeline: visualization





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC