Created
October 25, 2013 13:59
-
-
Save asuraphel/7155131 to your computer and use it in GitHub Desktop.
Anon inner classes
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
//: innerclasses/Parcel7.java | |
// Returning an instance of an anonymous inner class. | |
public class Parcel7 { | |
public Contents contents() { | |
return new Contents() { // Insert a class definition | |
private int i = 11; | |
public int value() { return i; } | |
}; // Semicolon required in this case | |
} | |
public static void main(String[] args) { | |
Parcel7 p = new Parcel7(); | |
Contents c = p.contents(); | |
} | |
} ///:~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment