final public class CRMS{
private ArrayList<Car>cars;
private ArrayList<Renter>renters;
private ArrayList<Transaction>transactions;
private int carid;
private int renterid;
public CRMS() {
cars = new ArrayList<Car>();
renters = new ArrayList<Renter>();
transactions = new ArrayList<Transaction>();
carid=1;
renterid=1;
}
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World by the GOAT programmar");
CRMS crms = new CRMS();
Basically I am having confusion on how the the cars array and renters array will be destroyed when the CRMS crms is destroyed by the garbage collector.Assuming there is nothing else in the main code
I expected the attirbute object arrays/lists to be destroyed upon the destruction of the crms object.
However my TA(Teacher Assistant) told me that this is not how it works. PS Can someone also tell whether this way of creating the object lists inside of the constructor is Composition or Aggregation.
Muhammad Nabeed Haider is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1