Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package nesting;
  2. public class Father {
  3. /* ============================================================
  4. methods in the class Father can access PRIVATE
  5. members of this NESTED class !!!
  6. ============================================================ */
  7. private class BankAccount {
  8. private double accountNumber; // *** Private variable !!! ***
  9. private String transferee; // *** Private variable !!! ***
  10.  
  11. public BankAccount (double x) {
  12. accountNumber = x;
  13. transferee = null; // It's good to make next to point to illegal null
  14. }
  15. }
  16.  
  17. private BankAccount bankAccount; // **** Access SHOULD be set to private ****
  18.  
  19. // Constructor
  20. public Father () {
  21. bankAccount = null; // Make an empty list
  22. }
  23.  
  24. /* ====================================================
  25. put( x ): store value x into the list
  26. ==================================================== */
  27. public void put (double x, String name) {
  28. BankAccount e;
  29.  
  30. e = new BankAccount(x);
  31. e.transferee = name; // You can use PRIVATE variables in BankAccount !
  32. // Store this in a server DB or pass it over REST
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement