Re: static class
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Sun, 18 Dec 2005 09:55:56 -0700
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
.
- References:
- static class
- From: raghu
- static class
- Prev by Date: Re: how do I make Class.forName("Integer") returning java.lang.Integer ?
- Next by Date: array list
- Previous by thread: static class
- Next by thread: Re: static class
- Index(es):
Relevant Pages
|