Sunday, December 21, 2014

Swap Index of Two values in Java List

boolean idFlag = false;

if(propertyList.contains("ID")){
idFlag = true;
int index = propertyList.indexOf("ID");
Collections.swap(propertyList, index, 0);
}

if(propertyList.contains("NAME")){
int index = propertyList.indexOf("NAME");
if(idFlag){
Collections.swap(propertyList, index, 1);
}else{
Collections.swap(propertyList, index, 0);
}
}


Give your valuable comment
Keep Visiting :)

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...