Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - Element removing while collection iterating -


i'm wondering going on behind scene when i'm executing following peace of code:

    list<object> list = new arraylist<object>();     fillthelist(); // filling list 10 objects     int count = 0;     (object o : list) {         count++;         if (count == 5) {             list.remove(count);         }         o.tostring();      } 

once element removed i'm getting concurrentmodificationexception exception.

i don't understand why after 1 of elements removing impossible take next 1 available in collection , proceed cycle.

get iterator instead of using iterator in for loop:

int count = 0;  for(final iterator iterator = list.iterator(); iterator.hasnext();) {     final object o = iterator.next();      if (++count == 5) {         iterator.remove();     }      o.tostring(); } 

edit: reason why concurrentmodificationexception because for loop using different iterator created before modification being made list.remove() , iterator has state inside.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -