开发者

Which will be more Efficent in j2me getter/setter or Hashtable

1.)I have c开发者_开发知识库reated j2me Application. I want to maintain settings Form. so i created class with getter/setter. i hope getter/setter will store in heap. Its same behavior to store that values into hash table. Which one will be efficient and less memory utilization.


I'm not sure I follow your question - do you mean you have created a class with attributes that correspond to fields in a Form? And that the Form uses getter and setter methods of the class to work with those attributes?

That should be more space efficient than using a java.util.Hashtable instance. The advantage of a hash table is that you can dynamically change the set of values stored. Disadvantage is that the populated hash instance will probably use more memory than your fixed set of attributes accessed via getter and setter methods.

Getter/setters should be quicker too - no hashing of the key object is needed - a method is associated with only one stored value. Also, you'll just be doing a value assignment compared to whatever storage managment the Hashtable will have to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜