Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. interface A {
  2. void someMethod();
  3. }
  4.  
  5. class B implements A {
  6. void someMethod() {
  7. // implementation here
  8. }
  9. }
  10.  
  11. class c implements A { //this should not allowed in this project
  12. }
  13.  
  14. // Hides the implementation details of ArrayList within a List variable
  15. List<String> strs = new ArrayList<String>();
  16. // Hides the implementation details of LinkedList within the same List variable
  17. strs = new LinkedList<String>();
  18. // All code using strs is agnostic to what kind of list it is (mostly)
  19. strs.add("Hello, Dolly");
  20. System.out.println(strs.get(0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement