Skip to content

Instantly share code, notes, and snippets.

@asuraphel
Created October 25, 2013 13:59
Show Gist options
  • Save asuraphel/7155131 to your computer and use it in GitHub Desktop.
Save asuraphel/7155131 to your computer and use it in GitHub Desktop.
Anon inner classes
//: 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