General Java Questions I
        }
        return ac;
    }
}
Note that the class AnotherClass, that extends MyClass, automatically becomes
Cloneable, because MyClass is Cloneable.
Also note, that super.clone() always returns an Object of the type of the actual object,
although the superclass doesn t know anything about that sub class. The reason is,
that Object.clone() is a native method, which just allocates new memory for the new
object and copies the bytes to that memory. Native code has it s own ways of finding
out which type to return ; )
  
Karl Schmidt
I was just wondering about the usefulness of Interfaces...
I was just wondering about the usefulness of Interfaces. I was under the impression
that interfaces could be used to perform multiple inheritance. But an interface only
declares a method   in a very abstract way.
A class that implements an interface needs to define its own implementation of a
certain method. What is the use of having an interface when nothing is being
gained...?
Answer: If two classes implements the same interface, you can get a reference to the
interface instead of the effective class without bother what class are you managing.
This is very useful in RMI (for example) or in any condition when you have to take an
object without knowing exactly his class, but only the interface that it implement.
For example:
public void recurseList( List l )
the generic List ensure that you can use every List for this method (ArrayList,
AbstractList, Vector...), so your calling method can be:
ArrayList l = new ArrayList(); or
Vector l = new Vector();
recurseList( l );
Without any problem.
by Davide Bianchi
 Q: I got a problem with an array/vector...
I got a problem with an array/vector.
my class contains a member:
static Vector quad[][];
....
file:///F|/a_jsite/350_tips/general_java I.htm (15 of 33) [2001 07 08 11:24:51]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved