I have three classes:

```
public abstract class fileHandler<Key extends Object, Value extends Object> {
}    

public A extends fileHandler<String, String[]> {
}

public B extends fileHandler<String, String> {
}

```

Now in my main function i do something like this:

```
fileHandler file= null;
If (<condition>) {
    fileHandler = new A();
} else
    fileHandler = new B():
}

```

But this gives 2 compile time errors:

1. Cannot convert A to fileHandler
2. Cannot convert B to fileHandler

How can I get rid of these errors as I don't get this error if base class is not generic.

### Update:

My class hierarchy is:

1. `class fileHandler<Key, Value> { }`
2. `class A extends fileHandler<String, String[]> { }`
3. `class B extends fileHandler<String, String> { }`
4. class C that calls function `gen(object of A)` or
5. class D that calls function `gen(object of B)`.
6. both C and D are derived from abstract class E.

Now how should I define these functions in C and D and E:

I gave the following:

### E:

```
public abstract void gen (fileHandler A) throws exception;

```

### C:

```
void gen (fileHandler A) throws exception;

```

### D:

```
void gen (fileHandler A) throws exception;

```

C, D, and E give error fileHandler is raw type. Reference to generic type fileHandler(Key, Value) should be parameterized.