Abstract Data Type VS Composite Data Type

edited March 2017 in Programming Questions

From my understanding, Abstract Data Type are data types that are described by their functions without actual implementation.

If that is the case, how are Strings, XML and P Vector ADT since they are explicitly implemented.

Also, composite data types, from what I know, are a group of primitive data types without functions, like Struct in C++. The Processing website described String, XML and Arrays as composite data types, how can they be composite data types when they have functions (like String.equals())?

Tagged:

Answers

  • edited March 2017 Answer ✓

    All non-primitives in Java can be called composite datatypes as well.

    B/c at their root they all end up being made outta primitive datatypes if we dig in till the end.

    For example the String class, which got 1 char[] array, plus some int fields for id & hashing.

    Its char[] array itself stores a fixed int length of char primitive values.

    As we can see, once we reach the root of each composite, we end up w/ primitive types only. :-B

    BtW, there are 8 primitive datatypes in Java: ~O)
    http://docs.Oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

    Also, there are no structs in Java. Only classes & interfaces. [-X
    Structs can only have fields as their members.
    While classes can have fields and/or methods as well. Plus constructors. :-bd

  • edited March 2017 Answer ✓
    • Using abstract as an adjective for datatypes is foreign in Java.
    • As already mentioned, there are 8 primitive datatypes in Java.
    • There's the special array datatype too. However this 1 doesn't have its corresponding class.
    • In addition to those 9 datatypes, all classes & interfaces create their own corresponding datatype.
    • Although the link between a datatype name and its corresponding class or interface is strong in Java, their concept is distinct.
    • Datatypes are used for variable declaration. That's what makes Java a strongly typed language.
    • But their corresponding class may happen to be declared abstract; which means it can have methods which still need to be implemented later, just like most interface's methods.
    • However, an interface or an abstract class don't cause their corresponding datatype name being called abstract as well. :-\"
  • Good read!

Sign In or Register to comment.