What it means to create an object will be expensive in java / oop

I have heard this statement many times while reading some java books / articles. My question is very simple, what when we say that creating some kind of object will be very expensive?

It is expensive here, for what and under what scenario should we use this term. It would be very easy for me to understand if anyone illustrates a small example and how to avoid it?

+4
source share
4 answers

Expensive usually means that it will take some time, but it may also mean that it will require a lot of other resources, such as memory, bandwidth, hosting budget, disk space or anything else that you would like to use less . For example,

new int[1000000000]

will be expensive because it allocates and zeros an incredible amount of memory.

+2
source

, , , -. , , . , , -, , ..

, .

+1

, (, io), . , , , .

+1

In the case of object-oriented programming, Costly refers to memory, resources, etc. which uses your object. If, unnecessarily, your object uses a lot of memory or resources, then somewhere you are not doing good programming.

+1
source

All Articles