Search code examples
javaclassjavadocsuperclass

superclass --- package vs class


RandomGenerator class is a subclass of Random class. They both have different packages. RandomGenerator is in acm.util package and Random class is in java.util class.

I don't understand how different packages fit within different classes. A package is a collection of different classes. Is this correct? If java.utilpackage has different classes in it and one of those classes is Random class. Does Random class have the acm.util packages in it? Are packages extensions of classes?


Solution

  • Package information can be found here and class inheritance can be found here 8.2-2, 8.2-3 and 8.2-4

    In short to subclass and subclass-able class both needs not to be in same package. I guess this is what puzzling you, how can one package can subclass from another package ?