Although I understand, the problem you say is that while you are installing more classes, you are going to be occupying more RAM memory with your program. If you are interested in an instance, you have two storage places (both in the ram):
The instances of your classes themselves are stored in the heap. That is, when doing a new ClaseA
, the only thing you are doing is creating the instance in the heap. Now if you make ClaseA a = new ClaseA();
you are creating a variable in the STACK (called: a) that has a reference to the instance, which is stored in the HEAP.
I leave an image where you can see, perhaps, more clearly what I try to explain:
I hope I have understood your doubt well.