aspose file tools*
The moose likes Performance and the fly likes Memory usage -- which is better? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Memory usage -- which is better?" Watch "Memory usage -- which is better?" New topic
Author

Memory usage -- which is better?

Kev Adams
Greenhorn

Joined: Oct 27, 2009
Posts: 23
I came across some code today that looks like this:



Would it not be better, not only for readability, but for memory usage to do it like this:



My thinking is that Java has to create a temporary memory space to hold whatever is returned by getObjA().getObjB().getObjC() each time.

Is that correct?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
Performance / memory use is not the issue here, the ability to debug and maintain the code is.

If any of those compound statements threw a NullPointerException, where would you look?

"Premature optimization is the root of all evil"

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memory usage -- which is better?