tags:

views:

157

answers:

1

1.)I have created 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.

+1  A: 

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.

HTH - apologies if I've misunderstood your question.

martin clayton