Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variables

 
Renu Radhika
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using member varibles or method variables which is more efficient for performance
 
Sachin Dimble
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More important than performance are other considerations - mainly, the principle that you must "keep variables as local as possibile".
 
John M Morrison
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic