Interfaces in Java
In Java, every interface should go into a separate file, and those files should not contain anything except the interface definition and its comments.
The name of that file must be the name of the interface
followed by the .java
suffix, which indicates
the file contains Java source code.
For simplicity, we will put all of a program's
*.java
files into a single directory.The Java system we will be using in this course requires a program's directory structure to be the same as its package structure. Putting all of a program's files into a single directory therefore implies we will be putting all of the program's code into the default package, which means you won't have to learn about Java packages.
The next slide shows a complete example of a Java interface.