1) Use sth else. 2) Should a getter method write?

colourwolf (色狼)
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.

2001-7-21 -04:00

回到话题: 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.

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论