Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class B {} // some class
- class A
- {
- B b = new B(); // composition - every A instance contains a B object
- void someMethod()
- {
- B c = new B();
- // not composition - it is a local variable
- // a B object is temporarily constructed on the stack when this method executes
- // and ends when this method ends.
- // It is not part of an A object
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment