IntelliJ Java IDE
The moose likes Performance and the fly likes Memory usage -- which is better? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply 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: 22
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: 11862
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

Java Resources at www.wbrogden.com
 
 
subject: Memory usage -- which is better?
 
Threads others viewed
Why this is compile time error
HashSet
Do we need synchroniation with Singleton Data class
abstract
JNI
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture