Abstract Data Type and Interface

前端 未结 8 1326
小鲜肉
小鲜肉 2021-02-04 18:26

I am new to Java. What is the difference between Abstract data type and Interface.

For Example We have a ListADT

interface MyListADT {
    void          


        
相关标签:
8条回答
  • 2021-02-04 19:22

    As per [wiki] http://en.wikipedia.org/wiki/Abstract_data_type

    In computer science, an abstract data type (ADT) is a mathematical model for a certain class of data structures that have similar behavior; or for certain data types of one or more programming languages that have similar semantics. An abstract data type is defined indirectly, only by the operations that may be performed on it and by mathematical constraints on the effects (and possibly cost) of those operations.

    For Java programming language

    you can take Java's List interface as an example. The interface doesn't explicitly define any behavior at all because there is no concrete List class. The interface only defines a set of methods that other classes (e.g. ArrayList and LinkedList) must implement in order to be considered a List.

    but the bottom line is that it is a concept

    0 讨论(0)
  • 2021-02-04 19:28
    What is the difference between Abstract data type and Interface.
    
    1. Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
    2. Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc.. check this link for info
    0 讨论(0)
提交回复
热议问题