Without trying to be too robust in this explanation... You may have noticed that in Java, we've sort of two categories of types, also known as data types: there are the 8 primitive data types, and then there's that whole other category of object types. Concerning the primitive data types, as mentioned there are 8 of them, and you likely won't be seeing any more. The definition of these types are very much part of the Java programming language (and runtime environment). So, you can't create a new one, since you can't change the language (and runtime environment). Then we have hundreds of object data types that folks are using - things like String, java.awt.Graphics, java.util.LinkedList, and java.text.DecimalFormat. Each of these object data types are defined by a class. You can create a new object data type by simply creating a new class. So, your confusion regarding the difference between class and type is probably well-based, and might mean that you're understanding the role of classes - they're primarily used to define object data types. Got it? [ May 06, 2004: Message edited by: Dirk Schreckmann ]
The term type is more general than class. Types in Java include primitive types and reference types - and the reference types include classes and interfaces. So "type" can mean primitive, class, or interface, while "class" means only class. Except that sometimes (often, actually) people say "class" when they really mean a class or interface. Or sometimes, a class, interface, or primitive. As an example, the class Class should really have been called Type, since it can represent interfaces and primitives as well. But Sun screwed up and called it Class, and now there's unnecessary confusion. Too late to change now though. As for subtype vs. subclass - same idea, but subtype includes interfaces too. So you can't say that List is a subclass of collection (well, you shouldn't anyway) but you can say it's a subtype.
"I'm not back." - Bill Harding, Twister
posted 16 years ago
ok, get it , thank dirk and jim for answer....i'm clear with these now ...tq [ May 07, 2004: Message edited by: Alvin chew ]
And then we all jump out and yell "surprise! we got you this tiny ad!"
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop