ArrayList.contains() method Vs if/else
807580Dec 31 2009 — edited Dec 31 2009sample.java
public sample {
public checkMethod(short val) {
// is the below comparison using if/else is best to use
short val1 = 1000;
short val2 = 2000;
short val3 = 3000;
if( val == val1 || val == val2 || val == val3) {
// some statements
}
// or Arraylist.contains best to use
Arraylist lst = new Arraylist();
lst.add(1000);
lst.add(2000);
lst.add(3000);
if(lst.contains(val)) {
// some stmts
}
}
please let me know which is best to use Arraylist.contains() or if/else.
Regards,
Subha
}