---
title: "How to solve Java generics name clash , has the same erasure?"  
description: "How to solve Java generics name clash , has the same erasure?"  
author: "Anonymous User"  
published: 2014-10-16  
updated: 2014-10-16  
canonical: https://www.mindstick.com/forum/2391/how-to-solve-java-generics-name-clash-has-the-same-erasure  
category: "java"  
tags: ["java", "oops"]  
reading_time: 1 minute  

---

# How to solve Java generics name clash , has the same erasure?

I have superclass Foo. And a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) Bar extending it.\

```
public class Bar extends Foo
```

[Function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) in Foo:\

```
protected void saveAll(Collection<?> many)
```

Function in Bar:\

```
public void saveAll(Collection<MyClass> stuff){    super.saveAll(stuff);}
```

**[Getting error](https://www.mindstick.com/forum/159638/getting-error-microsoft-office-interop-outlook-doesn-t-work) :\**

[Name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide) clash: The [method](https://www.mindstick.com/forum/166/webservice-method) saveAll([Collection](https://www.mindstick.com/articles/1718/collections-in-java)<MyClass>) of type Bar has the same erasure as saveAll(Collection<?>) of type Foo but does not override it.

## Replies

### Reply by Anonymous User

You are overriding the saveAll method with an incompatible type. Perhaps you want to do something like:\

```
public class Bar extends Foo<MyClass>Function in Foo<E>protected void saveAll(Collection<E> many)
```

and function in Bar:\

```
public void saveAll(Collection<MyClass> stuff){   super.saveAll(stuff);}
```


---

Original Source: https://www.mindstick.com/forum/2391/how-to-solve-java-generics-name-clash-has-the-same-erasure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
