Monday, 15 September 2014

java - Editing a value in array list -



java - Editing a value in array list -

i'm trying edit values saved in arraylist i'm stuck codes can't proceed u please help me it.. values in array codes title prereq cs101 computer cs210 cs102 process cs211

now want edit particular course of study

string code=request.getparameter("code"); string title=request.getparameter("title"); string preq=request.getparameter("preq"); @suppresswarnings("unchecked") list<prereqclass> prereqcl = (list<prereqclass>)request.getservletcontext().getattribute("preqattr"); for(prereqclass q:prereqcl){ if(q.getcode()==code){ } }

first, when comparing objects, utilize .equals() not ==, == compare object's reference.

second, convention class should start uppercase.

then, i'm not sure validation want before editing , treatment not specifying it.

still, your

if(q.getcode()==code)

is modified to:

if(q.getcode().equals(code))

you able come in status , modify object using it's setter/getter methods.

java arraylist edit

No comments:

Post a Comment