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
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: 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.

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论