David Thompkins wrote:Hi Knute, when you wrote
all classes are data types
does that also go for classes which I make myself? would I be correct in saying my poodle is not only of type dog but is of data type dog? if a create the following object:
Dog poodle = new Dog();
Absolutely. When you create a class, you have created a data type.
String is part of java.lang which is imported by default. I believe it is the only package that is. (Can anyone confirm?)
I found this "For convenience, the Java compiler automatically imports three entire packages for each source file: (1) the package with no name, (2) the java.lang package, and (3) the current package (the package for the current file)..." on stack overflow
I'm not quite sure what the 2 other packages besides java.lang are, it seems as though they are related to programmer created packages, I haven't read about putting my classes into own packages in headfirstjava yet but it was briefly mentioned earlier in the book that' it's possible.
Yes, it's coming back to me. The package with no name is probably the package you have been creating classes in. You get it when you don't have a package statement at the top of your program. And since package names relate to folders, you could be cd'd into a package when you start Java, which would be the current package.
Edit: it looks like I'm wrong about this: it's either the unnamed package, if you have no package statement, or the current package if you do.