**Situation:**

I want to write a generic function like the following:

```
public <T> void do(T para){
   para.something();
}

```

**Question:**
I want to give instances of two different classes to the do() function. Both classes are coming from an library, which has a bad design. Both classes have a something() method. But they are not implementing the same interface or extending the same superclass.

**My First though:**

I could write something like:

```
if(para instanceof A){
    ((A)para).something();
else if(para instanceof B){
    ((B)para).something();
}

```

I guess that would work, but I need to call something() more often and dont want to spam my code with this if/else. Has anyone a good clue? Thanks in advance!