Miguel schrieb:
[snip]
> -  class RidiculousFileFormatTokenizer {
> +  static class RidiculousFileFormatTokenizer {
[snap]
> 
> You have turned the RidiculousFileFormatTokenizer class into a 'static
> inner class' ...
> 
> Q: What is the motivation for turning this into a 'static inner class'?
> 
> Q: In this case, does it offer any advantages?
> 

An inner class holds a reference to the object of the enclosing class.
A nested class doesn't hold a reference to the enclosure.

sample:

class Enclosing{
        int a;
        class Inner{
                int b = a; // ok, it's an inner class
        }
        static class Nested{
                int c = a;  // this will produce a compiler error
        }
}

As a consequence a nested class requires less memory and speeds up the 
garbage collection due to fewer cross references between various objects.

further reading: 
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#262890


Thomas


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jmol-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to