This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variables" Watch "variables" New topic
Author

variables

Renu Radhika
Ranch Hand

Joined: Oct 21, 2005
Posts: 243
using member varibles or method variables which is more efficient for performance
Sachin Dimble
Ranch Hand

Joined: Dec 07, 2005
Posts: 100
Hi Renu!
I think method variables are more efficient as there scope are limited,they get created only when they required and get destroyed as method scope reaches but the same point is responsible for the major disadvantage of global usage!

Ranchers correct me if am wrong!

With Best Regards!
Sachin Dimble

--

- India_Will_Become_SuperITPower(new Lets_Go_ForIt());
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
More important than performance are other considerations - mainly, the principle that you must "keep variables as local as possibile".


ASCII silly question, Get a silly ANSI.
John M Morrison
Greenhorn

Joined: Jul 25, 2005
Posts: 21
Originally posted by Renu Radhika:
using member varibles or method variables which is more efficient for performance


This is not uniformly so. If you have constant data germane to various member functions, you might want to declare the data as a static instance variable. In this way, only one copy of the data is made when the class is loaded.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: variables