Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface A {
- void someMethod();
- }
- class B implements A {
- void someMethod() {
- // implementation here
- }
- }
- class c implements A { //this should not allowed in this project
- }
- // Hides the implementation details of ArrayList within a List variable
- List<String> strs = new ArrayList<String>();
- // Hides the implementation details of LinkedList within the same List variable
- strs = new LinkedList<String>();
- // All code using strs is agnostic to what kind of list it is (mostly)
- strs.add("Hello, Dolly");
- System.out.println(strs.get(0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement