tag:blogger.com,1999:blog-8712770457197348465.post2146013843884340874..comments2024-03-19T01:04:48.783-07:00Comments on Javarevisited: How to use Iterator and ListIterator in Java? Example Tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-8712770457197348465.post-43694257543772270932016-09-05T05:41:33.354-07:002016-09-05T05:41:33.354-07:00Iterator returned by synchronized Collection are f...Iterator returned by synchronized Collection are fail-fast while iterator returned by concurrent collections are fail-safe in Java.<br /><br />worth adding<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2622797103104053462015-09-14T05:21:01.837-07:002015-09-14T05:21:01.837-07:00Dear @suresh, you are not calling Iterator's r...Dear @suresh, you are not calling Iterator's remove method, instead you are calling ArrayList's remove method which is the cause of ConcurrentModificationException. <br /><br />You are doing <b>str.remove("abc");</b><br /><br />Instead, you should do :<br /> <b>itr.remove("abc");</b><br /><br />Don't worry this is the classic mistake every Javajavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6437870059962735632015-09-14T04:12:40.011-07:002015-09-14T04:12:40.011-07:002nd point is not working i.e "If you want to...2nd point is not working i.e "If you want to remove objects from Collection than don't use for-each loop instead use Iterator's remove() method to avoid any ConcurrentModificationException".<br /><br />If List itself is not concurrent i.e If it is not CopyOnWriteArrayList then iterator throws concurrent exception while calling remove method.<br /><br />List str = new ArrayList(suyashhttps://www.blogger.com/profile/14397448369116266288noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-27329274983198939962015-01-18T22:56:58.077-08:002015-01-18T22:56:58.077-08:00How to retrieve values in a table using list????Pl...How to retrieve values in a table using list????Please answer.<br />I created database table in one class and list in another class.Anonymoushttps://www.blogger.com/profile/01836148524633702957noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52010566738854426312014-03-05T10:22:32.126-08:002014-03-05T10:22:32.126-08:00can you please tell me what is the design pattern ...can you please tell me what is the design pattern used in iterator<br />Anonymoushttps://www.blogger.com/profile/03101033650986536494noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-85216059743415861112013-04-29T18:24:32.823-07:002013-04-29T18:24:32.823-07:00Can you give me an example of Fail Fast Iterator a...Can you give me an example of Fail Fast Iterator and FailSafe IteratorAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-53787891482565621572013-04-19T04:32:18.699-07:002013-04-19T04:32:18.699-07:00very nice explanation of iterator concept.I was co...very nice explanation of iterator concept.I was confused about iterator concept,but now clear after reading this block.Anonymoushttps://www.blogger.com/profile/15081599421164420306noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-44743349657304054232013-02-21T19:19:24.315-08:002013-02-21T19:19:24.315-08:00What is benefit of using Iterator over for each lo...What is benefit of using Iterator over for each loop or simply for loop with index? Did you measure performance of Iterator for different collections like ArrayList, LinkedList or HashSet?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-4273777675630938952012-02-13T17:46:48.463-08:002012-02-13T17:46:48.463-08:00What is benefit of using iterator in Java, Can'...What is benefit of using iterator in Java, Can't we do iteration using for loop? with java5 for loop its even more clean and easy rather than using an Iterator object which I am sure take more memory.Sonyanoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-28657710529509019332012-02-05T21:41:04.155-08:002012-02-05T21:41:04.155-08:00I want to implement my own Iterator in Java, Can y...I want to implement my own Iterator in Java, Can you please let us know how to write own iterator in Java with sample code, thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-31014520326871743952011-12-01T00:48:47.318-08:002011-12-01T00:48:47.318-08:00Simple and best Java Iterator Tutorial. Iterator i...Simple and best Java Iterator Tutorial. Iterator in Java looks confusing to me initially but after reading your tutorial now I can use Java iterator and now thinking to write my own iterator by implementing iterator interface, would be great if you could share guide lines on writing your iterator in JavaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-49663558243693752832011-11-18T17:35:00.273-08:002011-11-18T17:35:00.273-08:00@Rajiv, brother is correct. Iterator is a design p...@Rajiv, brother is correct. Iterator is a design pattern which allows to traverse or retrieve data and Java Iterator is just an implementation of that pattern. Thanks Rajiv and brother for your comments.Javin @ OutOfMemoryError in Javahttp://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-4360914505071167722011-11-18T10:26:01.333-08:002011-11-18T10:26:01.333-08:00Hi rajiv , design patterns is so difference than c...Hi rajiv , design patterns is so difference than collection .design patterns follow the mvc pattern and iterator is a class which is retrieving/traverse data from array list and so..Solution & Technologies finderhttps://www.blogger.com/profile/00201910024103566834noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-20072813009073351522011-11-07T07:24:52.640-08:002011-11-07T07:24:52.640-08:00Hi Javin,
does iterator in Java and iterator desig...Hi Javin,<br />does iterator in Java and iterator design patterns are same thing or different ?Rajivnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-71865463386458152892011-11-07T07:24:08.621-08:002011-11-07T07:24:08.621-08:00@Ravindra, fail-fast iterators are those who throw...@Ravindra, fail-fast iterators are those who throw ConcurrentModificationException if collection is modified structurally by another thread when one thread is iterating over it. while fail-safe iterators are mostly work on copy of collection object instead of original collection object and hence not affected by such changes.Javin @ Spring interview questionshttp://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-49165763336018204862011-11-01T23:18:45.705-07:002011-11-01T23:18:45.705-07:00I have heard about two types of Iterator in Java, ...I have heard about two types of Iterator in Java, fail-fast and fail-safe, Can you please explain difference between Fail-fast and Fail-Safe Iterators ?Ravindranoreply@blogger.com