JavaFundamentals5 L2 1
JavaFundamentals5 L2 1
Interfaces
Interfaces
•It’s a reference type, similar to a class.
•Can contain only constants, method signatures, default
methods, static methods, and nested types.
•Method bodies exist only for default methods and static
methods.
•Interfaces cannot be instantiated.
•In its most common form, an interface is a group of
related methods with empty bodies.
Interfaces
•Implementing an interface allows a class to become
more formal about the behavior it promises to provide.
•Interfaces form a contract between the class and the
outside world, and this contract is enforced at build time
by the compiler.
•All methods defined by that interface must appear in its
source code before the class for it to compile
successfully.
Interfaces
Default Methods.
•Default methods enable you to add new functionality
to the interfaces of your libraries and ensure binary
compatibility with code written for older versions of
those interfaces.
Static Methods.
•A static method is a method that is associated with
the class in which it is defined rather than with any
object. Every instance of the class shares its static
methods.
References
http://www.javaworld.com/article/2078645/java-se/jvm-performance-optimization-part-
3-garbage-collection.html
http://www.javatpoint.com/Garbage-Collection
http://www.journaldev.com/4098/java-heap-space-vs-stack-memory
http://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-jav
a
http://java-questions.com/java-memory-model-and-garbage-collections.html
http://www.oracle.com/technetwork/tutorials/tutorials-1876574.html
https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
https://docs.oracle.com/javase/tutorial/java/concepts/interface.html
http://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html
https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
https://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html
https://docs.oracle.com/javase/tutorial/java/concepts/package.html
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html