Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > does static mean there is only one of?

Reply
Thread Tools

does static mean there is only one of?

 
 
nileppez
Guest
Posts: n/a
 
      08-16-2003
is that why main() is always static?
does it mean that there can't be any instances of that method? (I mean
the class that contains main won't ever be reproduced)

am i right here?
i've never understood what static is for.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      08-17-2003
On 16 Aug 2003 16:18:15 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (nileppez)
wrote or quoted :

>is that why main() is always static?
>does it mean that there can't be any instances of that method? (I mean
>the class that contains main won't ever be reproduced)


You have instances of classes, not methods. There is only one class
object and main in a method of that class. It has no direct access to
the instance fields since there is no object of that class
instantiated. Main of course can instantiate objects, then use their
instance fields and methods.

see http://mindprod.com/jgloss/static.html
and http://mindprod.com/jgloss/instance.html

I think I was less tongue-tied explaining it there.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
 
Harald Hein
Guest
Posts: n/a
 
      08-17-2003
"nileppez" wrote:

> is that why main() is always static?
> does it mean that there can't be any instances of that method?


Methods don't have instances. Classes have. These instances are called
objects.

Static methods are not related to instances, they directly belong to
the class. Because of this, you don't have to have an object before you
can call them. All you need to know is the class name.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
weighted mean; weighted standard error of the mean (sem) C Barrington-Leigh Python 1 09-10-2010 02:03 AM
Why does << operator work only when there is at least one cout? Mc Lauren Series C++ 5 06-10-2009 07:11 AM
What does this static function mean? dolphin C++ 4 11-05-2007 01:54 PM
what does 'this' mean if it static opistobranchia C++ 12 11-12-2005 09:44 PM
If it ONLY lists Widescreen, does it mean (that) DVD has NO Std. 4:3 TV display option? Curious Angel DVD Video 30 08-02-2004 02:17 PM



Advertisments