Skip to content

Instantly share code, notes, and snippets.

@tyano
Created May 30, 2014 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyano/9c7a4ee4e9922ff13937 to your computer and use it in GitHub Desktop.
Save tyano/9c7a4ee4e9922ff13937 to your computer and use it in GitHub Desktop.
package jp.javelindev.snippets;
public class Java8Sample {
public static void main(String[] args) {
Laco laco = new Laco();
SampleClass sample = new SampleClass();
sample.func(laco); //ClassCastException SomeClassはLacoにキャストできません
}
}
class SomeClass {
}
class Laco extends SomeClass {
}
class SuperClass<T extends SomeClass> {
public void func(T item) {
}
}
class SampleClass extends SuperClass<Laco> {
@Override
public void func(Laco item) {
System.out.println("func is executed.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment