Challenges master: JAVA nested classes.

Category: Java SE
2009-08-08 08:05:36

Sponsored Links
In JAVA class nested class has two kinds, static and non-static,
two kinds of very different,
even still Sidongfeidong!
seeking master Ariadne,
certainly score both hands!

Sponsored Links

2009-08-08 08:09:30
suggest looking <JAVA > Chapter 7, Section 6.
on this issue very detailed.
2009-08-08 08:25:25
internal class!

features: static inner classes are compiled into a single. class file, this file independent of its outer class. Static inner class by definition outside the class can access the protected domain and private domain.
be treated with caution!

general use of the test.
2009-08-08 08:45:06
All static class variables and methods in memory only one instance, no matter how many instances of your class.

internal static class if it is, then the reason is you static inner classes can not require an external instance of the class can be created. Like the class as a static method, as you can new Rectangle2D.Double (..);
Double inner class as Rectangle2D.

rather than static, you need to create such Double (...) ;/ / rect as Rectangle2D instance
that you have to have an external instance of the class in order to create an internal classes.

typical design is an external class is an abstract parent class, sub-class as static inner classes only methods, no variables (variables are defined in the parent class, or all of the co-owner of an inner class instance variable). Like
2009-08-08 08:49:49
Even still do not understand
2009-08-08 09:05:20
no one know?
2009-08-08 09:26:43
word, static inner classes can be used when the outer class, but at the same time both within the class dynamic ability.
2009-08-08 09:55:08
class does not need to access the inside of his external class, you can define it as a static inner class, it can also be called a nested class. Specific needs in specific examples appreciate
2009-08-08 10:33:41

say is what ah

2009-08-08 11:02:17
CSDN no master?
2009-08-08 11:19:14
static and non-static class? See scjp tutorials, which have inner class differences and connections. For the static inner class, you can become a top-level class is an external access, such as: Graphics2D.Double such a class of non-static, such as:
xxx.addMouseAdapter (new MouseAdapter () {
public void mouseClick (MouseEvent e ) {
;/ / implemented here.

mainly in the scope and variable access capabilities are different.
2009-08-08 11:34:25
raised if the internal class, write another one. java program, the external class also write another one. java
and written in such a What is the difference together?
2009-08-09 12:08:02
still not clear
2009-08-09 12:24:28
I'm reading this book
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.