Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dr. No

macrumors regular
Original poster
Sep 13, 2003
193
0
Can someone explain what an Abstract Data Type is in Java? Plus, what does it look like, and what does it do?
 

kanaka

macrumors member
Jul 8, 2002
86
0
Dr. No said:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.