Created
August 10, 2012 13:37
-
-
Save buzztaiki/3314255 to your computer and use it in GitHub Desktop.
内側の無名クラスから外側の無名クラスを見る
This file contains hidden or 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
| import java.util.Comparator; | |
| public class A { | |
| public static void main(String[] args) throws Exception { | |
| new Comparator<String>() { | |
| public int compare(String a, String b) { | |
| new Runnable() { | |
| public void run() { | |
| try { | |
| Comparator cmp = (Comparator)this.getClass().getDeclaredField("this$0").get(this); | |
| System.out.println(cmp.toString()); | |
| } catch (Exception e) {} | |
| } | |
| }.run(); | |
| return a.compareTo(b); | |
| } | |
| }.compare("a", "b"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment