Java logger allows you to use the following syntax:
m_logger.info("ID: {} NAME: {}", id, name);
m_logger.info("ID: " + id + " NAME: " + name);
In the first case, in fact, we call the function ..., and each time a new one is created Object[].
I ran through YourKit and this is what I see.
My question is, is this not the first case of an expensive operation that we must avoid all the time? But still I have seen this in many codes. What do we get using # 1?
And I suggest that for best performance we should use StringBuilder?
source
share