Created
May 30, 2014 17:45
-
-
Save tyano/9c7a4ee4e9922ff13937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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