Last active
June 4, 2019 19:40
-
-
Save jayanthrbharadwaj/afecefb8c6298cd5c80f9b8af4d7202d to your computer and use it in GitHub Desktop.
Nested Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nesting; | |
public class Father { | |
/* ============================================================ | |
methods in the class Father can access PRIVATE | |
members of this NESTED class !!! | |
============================================================ */ | |
private class BankAccount { | |
private double accountNumber; // *** Private variable !!! *** | |
private String transferee; // *** Private variable !!! *** | |
public BankAccount (double x) { | |
accountNumber = x; | |
transferee = null; // It's good to make next to point to illegal null | |
} | |
} | |
private BankAccount bankAccount; // **** Access SHOULD be set to private **** | |
// Constructor | |
public Father () { | |
bankAccount = null; // Make an empty list | |
} | |
/* ==================================================== | |
put( x ): store value x into the list | |
==================================================== */ | |
public void put (double x, String name) { | |
BankAccount e; | |
e = new BankAccount(x); | |
e.transferee = name; // You can use PRIVATE variables in BankAccount ! | |
// Store this in a server DB or pass it over REST | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment