Created
March 5, 2014 16:20
-
-
Save anonymous/9370498 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
public class Fun { | |
public static void main(String[] args) { | |
// Creating the subclass. (1) | |
MySubclass mySubclass1 = new MySubclass() { | |
public int compareTo(Object o) { | |
return 0; | |
} | |
}; | |
// Creating the super class. (2) | |
MyClass<Integer> myClass1 = new MyClass<Integer>() { | |
public int compareTo(MyClass<? extends Integer> i) { | |
return 0; | |
} | |
}; | |
// We could also do this, since the constructor is parameterised. (3) | |
MyClass<Integer> myClass2 = new <String,String>MyClass<Integer>() { | |
public int compareTo(MyClass<? extends Integer> i) { | |
return 0; | |
} | |
}; | |
// (1) | |
$$ $$ = new $$ () { | |
public int compareTo(Object o) { | |
return 0; | |
} | |
}; | |
// (2) | |
$<$> $_ = new $<$>() { | |
public int compareTo($<? extends $> $) { | |
return 0; | |
} | |
}; | |
// (3) | |
$<$> _$ = new <$,$>$<$>() { | |
public int compareTo($<? extends $> $) { | |
return 0; | |
} | |
}; | |
} | |
} | |
// A comparable, parameterised class, which extends Thread. | |
abstract class MyClass <T> extends Thread implements Comparable<MyClass<? extends T>> { | |
// Has a field, of current type, parameterised with itself (What a mess!) | |
MyClass<MyClass> myClass; | |
// Parameterised constructor | |
<MyClass, Y> MyClass() { | |
myClass = myClass.myClass; | |
} | |
// Inner interface. | |
interface MyInterface { | |
<MyInterface extends MyClass> MyInterface interfaceMethod(); | |
} | |
} | |
// Subclass of the above, which implements the innter interface. | |
abstract class MySubclass extends MyClass implements MyClass.MyInterface { | |
// Nested class (extending error) with one method, which returns a copy of the class. | |
class MyError extends Error { | |
MyError errorMethod() { | |
return new MyError(); | |
} | |
} | |
// Implementation of the previous nexted interface - throws the above error class we have. | |
public <MyInterface extends MyClass> MyInterface interfaceMethod(){ | |
throw new MyError().errorMethod(); | |
} | |
} | |
// Original | |
abstract class $ <_> extends Thread implements Comparable<$<? extends _>>{ | |
$ <$> $; | |
<$, $1> $ () { | |
$ = $.$; | |
} { | |
} | |
interface _ { | |
<_ extends $> _ $(); | |
} | |
} | |
abstract class $$ extends $ implements $._ { | |
class _$ extends Error { | |
_$ $ () { | |
return new _$(); | |
} | |
} | |
public <_ extends $> _ $(){ | |
throw new _$().$(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment