Is there any difference in efficiency between the 2 code snippets below? Does the first one require it to allocate memory for the object?
Class c = a.getClass();
if(str != null)
c.dosomething(c.getX())
if(a.getClass() != null)
a.getClass().doSomething(a.getClass().getX());
First one will be much more efficient, especially if the getObject method is expensive.
If any memory is allocated for c, this is done inside the getObject method.