I interpret your question as, "how does one class use another class".
class A, has to initialise class B in order to use the operations B offers (that is, it's public interface).
If you paste the above in a file called A.java and compile it (javac A.java) and run it (java A) you'll see "Im class B!". A uses B's print class. It cannot use B's myOwnMethod however, since it's private.. but B can use it itself.
Hope the above helped.
Joined: May 18, 2005
it's that simple? Thanks. I'll apply and practice. Thank you very much
Originally posted by Lawrence Buensalida: it's that simple?
Err no not really. The example given was the simplest form of calling a method from one class by another. Read up on packages and on the different forms of encapsulation in Java. What would of happened if the method had been static, for example? Here is a link to the
Java Tutorial. Also how do you need to modify your classpath when calling a method from a class within a Jar file?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com