PDA

View Full Version : Abstract Data Types




Dr. No
Dec 11, 2005, 09:29 PM
Can someone explain what an Abstract Data Type is in Java? Plus, what does it look like, and what does it do?



kanaka
Dec 11, 2005, 10:31 PM
Can someone explain what an Abstract Data Type is in Java? Plus, what does it look like, and what does it do?
An Abstract Data Type (ADT) in any programming language is an entity that is only defined by the type of data stored and the operations that may be performed on that data. That is, the operations of an ADT are defined in a public interface, but the specific way in which the operations are implemented is hidden within the ADT. The person using the ADT doesn't need to know anything about the implementation details.

A common example of an ADT is a list. A list may have a set of public methods to insert or remove objects, but the implementation details are hidden inside the ADT. The list might be implemented using an array or a linked-list, but the person using the class doesn't need to know or care about these details.

In Java, ADTs are frequently created by defining in interface, and then concrete classes "implement" the interface. http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
There are also Abstract classes and abstract methods in Java, but it sounds like you're asking more about the general ADT concept.

http://en.wikipedia.org/wiki/Abstract_data_type