This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / VAJ3.5. (1)How to reuse Enumeration? How can I move the point to top after once enum.hasMoreElements() again? (2)Creating CMP, there's one checkbox: Make getter read-only. Can GETTER write anything except read? tks.VAJ3.5. two questions: 1.how to reuse Enumeration? after once enum.hasMoreElements(), I hope I can reloop several times. However, it seems the point is on the bottom. How can I move the point to top again? 2.When creating CMP, there's one checkbox: Make getter read-only. what's the meaning? Can GETTER write anything except read? tks.
-howru(How are you?);
2001-7-21
{337}
(#139786@0)
-
1) Use sth else.
2) Should a getter method write?1) Java Enumeration is 1-way street. If you want to revisit, you should get sth else, or cache the references in sth like an ArrayList:
ArrayList list = new ArrayList();
while( enum.hasMoreElements()) list.add( enum.getNextElement());
Most of times you don't need this because normally there are other REVISITABLE data structures (such as Object[]) provided to do this trick.
2) A getter should be a read-only method. By making it writing, you are defeating the purpose of the method.
-colourwolf(色狼);
2001-7-21
{493}
(#140017@0)
-
I don't think you can reuse enumeration after you loop out, how about chnage to Vector? For CMP I just guess If you don't select read only , it should be default set & get
-uid(miracle);
2001-7-21
(#140025@0)
-
Thank you 色狼 and Miracle! In fact, no matter I select Readonly or not, I can use set & get without problem. I just don't understand, why IBM give us a choice: Readonly or not to a Getter.There must be something in Getter I don't know.
-howru(How are you?);
2001-7-22
{48}
(#140782@0)