Consider the following two Java files that contain a simplified version of my issue
#a.java
package a;
public interface I {
//...
}
#b.java
package b;
public interface I {
//... (different stuff from a.I)
}
You'll notice within my project there are two interfaces named "I". This cannot be changed. I am in a situation where I need to use both types inside a single class. Now of course, I could just reference each of their types as a.I and b.I, but I'm trying to avoid it for nothing other than maintaining readability.
I want to do something like this
interface B extends b.I {
}
This could let me use the interface of I by using B and, and a.I as just I by importing. The problem is that this doesn't work, let's take this concrete example using
interface MyList extends List<String> {
}
MyList l = new ArrayList<String>();
This yields a type error. Why doesn't Java "know" that MyList extends List?
Also, I've tried casting in the above example, but it generates a ClassCastException
Thoughts?