Question: in my code have

```
SearchBean sb=new SearchBean();
final static ArrayList<SearchBean> result=new ArrayList<SearchBean>();
public void addData()
{
.
.   (Adding data from data base into SearchBean object
.
result.add(sb);
}
public ArrayList<SearchBean> sendResult()
{
  return result;
}

```

Now i'm `return result`. first time it is giving correct but second time again that object also will be adding.
for example first time searching result `syam`(correct result) 
in second time searching actually `Ram` is the coorrect result but `syam,Ram` also coming...
please help me ...

```
how to remove old data into ArrayList?

```

Answer: 
Make it a local variable instead of a `static` field.

In general, using a local variable instead of a field is a good idea, but in your case it would fix a bug. ;)

---

I would have method like

```
addDataAndSendSearch(); // List is only in this method.

```

or

```
List<SearchBean> list = generateSearch();
sendSearch(list);

```

or

```
List<SearchBean> list = new ArrayList<>();
match1.addData(list);
match2.addData(list);
sendSearch(list);

```

in each case you can see

* I don't re-use a list, global or other wise.
* The list is passed to any method which needs it. There is no chance of getting an old value.
Because once you add something in `ArrayList` it remains there unless you call `remove()` or `clear()`