Tag Archives: Java

Easy to remember: Composition vs Aggregation

As a rule of thumb: In composition (Person, Heart, Hand), aggregated objects (Heart, Hand) will be destroyed as soon as Person is destroyed. In aggregation (City, Tree, Car) aggregated objects (Tree, Car) will NOT be destroyed when City is destroyed. … Continue reading

Posted in Java | Tagged , | Leave a comment

Public, protected, default and private in Java

Here is some simple rules to memorize these access modifiers : private: class scope. default (or package-private): package scope protected: package scope + child (like pakage, but we can subclass it from different pakages). The protected modifier always keeps the … Continue reading

Posted in Java | Tagged | Leave a comment

Work with IO Stream in Java

In java, one can divide streams into two main types: Connection streams, which Java use to directly connect to the source data (File on external memory, Network stream…): – FileInputStream/ FileOutStream is used to read binary file – FileReader/FileWriter is … Continue reading

Posted in Java | Tagged | Leave a comment