Aashiqui Posted March 19, 2015 Report Posted March 19, 2015 I got a list of element where i need to add a new element into it and get the value depending upon id values.. public Array( int Id, String text, int requestId, //int totalNotes, ) { super(); this.Id = Id; this.text = text; this.requestId = requestId; //this.totalNotes = totalnotes; } so all these values are set using sql query result but the element which i need to add has seperate query and which runs on the Id element value.. so how i can add that new element into the list.
VenkatD Posted March 19, 2015 Report Posted March 19, 2015 http://stackoverflow.com/questions/8644176/how-can-i-add-elements-in-hashmap neeku aa ID or index kavalante .. go with MAP
Aashiqui Posted March 20, 2015 Author Report Posted March 20, 2015 may be nenu clear gaa cheppaledhu emo. eppudu okka list lo elements vunnayilist<elements> elements{A,B,c,D} so nenu aa list ne iterate chesi A value tesukoni pass to some method and result should eb assign to D in the list so lsit lo element ki value ela assign chestharu +1
phoenix_nebula Posted March 20, 2015 Report Posted March 20, 2015 Iteration time lo for( Iterator it :list L ){ If A --do something ........etc if(key = D){ D= callTheQuerywhichusesA&B&C(); } }
Aashiqui Posted March 20, 2015 Author Report Posted March 20, 2015 yeah iterate chesthuna...and value set back ela cheyali aa element ki Iteration time lo for( Iterator it :list L ){ If A --do something ........etc if(key = D){ D= callTheQuerywhichusesA&B&C(); } }
RunRaajaRun123 Posted March 20, 2015 Report Posted March 20, 2015 yeah iterate chesthuna...and value set back ela cheyali aa element ki Setback means u need to replace D with the result frpm the method ??
phoenix_nebula Posted March 20, 2015 Report Posted March 20, 2015 Are u thinking of changing the value of the key ?
RunRaajaRun123 Posted March 20, 2015 Report Posted March 20, 2015 If you want to replace d get the index of it and use set method to replace it
phoenix_nebula Posted March 20, 2015 Report Posted March 20, 2015 Check this thread http://stackoverflow.com/questions/4235774/changing-hashmap-keys-during-iteration ,,,read all solutions and try one by one
Recommended Posts