I'm a beginner Java programmer and have been experiencing difficulty grasping what the big picture of implementation is in OOP in the Java language.
I will try to frame my question with the pseudocode below (apologies if it is not that pretty):
interface{
foo();
}
class a {
//stuff
foo() OPERATIONS;
}
class b {
//stuff
foo() OPERATIONS;
}
//The OPERATIONS segment is actually the *work* the foo does: i.e., if foo were
//print, it would be the System.out.println("");
Now, what is the purpose of an interface, if it is within the actual classes that the interface's 'foo' OPERATIONS are declared? I thought the purpose of an interface was to create, if you will, a 'method grab bag' that is outside of all of the class obfuscation to keep from having to restructure the hierarchy that could be modified in one portion of code and apply to many implementing classes. In other words, I imagined an interface would be like what a function would be used for in 'C' language: a sequestered and concise set of operations clustered together and encapsulated to be called on when needed, and grouped in a code segment so that one could modify the OPERATIONS of foo within the interface and it apply to ALL classes implementing the interface. What am I missing?
Thanks!