How to extend multiclass

Hi, can java hava more than one super classes?how can built a class with many super classes using extends?thank you!
[151 byte] By [yeahking] at [2007-9-26 1:32:42]
# 1

No,

A java Class can only extend ONE class.

You can simulate multiple inheiritance by implementing interfaces.

Define interfaces that have a set of functionality (i.e. java.util.List)

and implement them on your class. This allows you to abstract the functionality

and apply it to non-hierarchical objects.

Another way to do this is to create a wrapper class that

provides the same functionality through a wrapper and then add your own specific

functionality through inheritance and/or by implementing and interface.

class PersonVector extends SomeOtherClassNotVector implements SomeInterface {

private Vector v;

public Person [] getPeopleNamedBob() {...}

public void add(Object o) {...}

public boolean contains(Object o) {...}

etc...

}

Check out the book "Effective Java" by Josh Bloch!

I hope this helps!

lordkilgour at 2007-6-29 1:34:07 > top of Java-index,Archived Forums,Java Programming...
# 2

A subclass can only extend one class so that it has one direct parent. Now, a subclass can extend a class which extends a class.

For Example, a JFrame extends Frame which extends Window, which extends Container, and so forth. But JFrame can't extend both Frame and Window.

Side Note:

One class can implement multiple Interfaces.

Hoju at 2007-6-29 1:34:07 > top of Java-index,Archived Forums,Java Programming...