I read that a character array in C is a composite data type because it is a sequence of characters, but then in Java a String is a class and Wikipedia says that a class is data structure, I am confused.
"Data structure" is a very general term of theoretical computer science. Any technique for the organization of machine-manipulable data can be thought of as a data structure. Even a single machine integer is a data structure, because there's more than one way that the bits could be interpreted. Most often, though "data structure" is used to refer to the organization applied to a large collection of data: for instance, a binary tree, a hash table, a flat array, or a linked list. And usually when people talk about data structures they do it in generic terms, not specific to a particular programming language.
"Composite data type" is a term-of-art of C and related languages, meaning "any language data type that isn't a machine number", more or less. Composite data types are data structures, but not all data structures are composite data types -- machine numbers are too simple to be composite data types, and a complex data structure is likely to be built out of several composite data types.
"Class" is a term-of-art of object-oriented programming languages, referring to a data type that defines not only data but "methods" for manipulating the data. In C++, all class types are composite data types, but not all composite data types are class types (the others are "plain old data", or "POD", types).
"String" is the generic term for a data structure that holds a sequence of small machine integers that somehow represent text. Just about every programming language has some notion of a string, but no two of them are the same. Strings are by definition data structures. In the C family, strings are always composite data types, because a single machine integer is not big enough for more than a few characters. In object-oriented programming languages, strings are usually, but not always, class types.
I hope this at least advances you to a more sophisticated level of confusion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With