In the current problem I have ( printing a file to a physical printer in Java ). I execute the code like crazy trying to absorb any useful missing information from the javadoc of each class used.
Now I pulled this code from the previous questions, so there was an honest bit that I didn't write myself. The problem I noticed is that the code I grab initializes an object, say, "SimpleDoc", which implements an interface (Doc) and assigns it to that interface ?!
A small piece of code:
Doc mydoc = new SimpleDoc(textStream, flavor, null);
Now, as I understand it, in java we create objects. I am familiar with inheritance, and I am familiar with the trick of using interfaces to let a class “inherit” several superclasses.
But it just doesn't stick. You can create a class that implements the interface, and that's fine with me. But what happens when an interface is created and the object is reduced to its interface? What do I get when I access mydoc for sure?
java object initialization interface netbeans
Alex
source share