Re: static class



raghu <raghujindia@xxxxxxxxx> wrote:
> what is meant by static class?
> how do u define it?
> where will we use it?

There are two commonly used definitions of that term. Because there are
two, it's worth being very explicit in communication about which you
mean, if it's not obvious from context.

The first meaning is a class that is merely a collection of static
things. That is, you aren't supposed to create an object of that class.
You are just supposed to call its static methods. An example is
java.lang.Math. This has been called a "static class" by many people
since at least Java 1.0.2, the initial release more than ten years ago.
I don't know if the term is used in any other languages, but I hadn't
heard it until Java.

In Java 1.1, the situation was confused by adding a second meaning.
Java 1.1 provides the option of declaring nested classes, and those can
be declared static, meaning that they aren't inner classes and therefore
don't contain a reference to an object of the outer class. So it makes
sense to call these "static". To avoid confusion, they are often called
"static nested classes" instead of just "static classes"... but it's
possible that's what your source meant.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.



Relevant Pages

  • Re: Weird Behaviour
    ... > ONE sentence in order to dispute this commonly understood meaning. ... Here's the problem IMO. ... Given this brain-dead method: ... But if java were PBR: ...
    (comp.lang.java.help)
  • Re: unicode
    ... You can't change the meaning of existing code, but if some language ... changed the definition in Java 1.8. ... the search for a superior moral justification for selfishness. ...
    (comp.lang.java.programmer)
  • Re: unicode
    ... You can't change the meaning of existing code, ... changed the definition in Java 1.8. ... Roedy Green Canadian Mind Products ... the search for a superior moral justification for selfishness. ...
    (comp.lang.java.programmer)
  • Re: (Probably) easy question about inheritance
    ... Vector has specific meaning already in Java, ... If Vec extends Matrix then Vec has MORE fields and methods than ... The Java Glossaryhttp://mindprod.com ... Vectors for math purposes because that's what they're called, ...
    (comp.lang.java.programmer)