OnJava8-Examples/enums/NotClasses.java

48 lines
1.1 KiB
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// enums/NotClasses.java
// (c)2021 MindView LLC: see Copyright.txt
2015-11-15 15:51:35 -08:00
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
// {ExcludeFromGradle}
// javap -c LikeClasses
2015-06-15 17:47:35 -07:00
enum LikeClasses {
WINKEN {
@Override void behavior() {
2017-01-20 21:30:44 -08:00
System.out.println("Behavior1");
}
2015-06-15 17:47:35 -07:00
},
BLINKEN {
@Override void behavior() {
2017-01-20 21:30:44 -08:00
System.out.println("Behavior2");
}
2015-06-15 17:47:35 -07:00
},
NOD {
@Override void behavior() {
2017-01-20 21:30:44 -08:00
System.out.println("Behavior3");
}
2015-06-15 17:47:35 -07:00
};
abstract void behavior();
}
public class NotClasses {
// void f1(LikeClasses.WINKEN instance) {} // Nope
2015-09-07 11:44:36 -06:00
}
/* Output: (First 12 Lines)
2015-06-15 17:47:35 -07:00
Compiled from "NotClasses.java"
abstract class LikeClasses extends
java.lang.Enum<LikeClasses> {
public static final LikeClasses WINKEN;
2015-06-15 17:47:35 -07:00
public static final LikeClasses BLINKEN;
2015-06-15 17:47:35 -07:00
public static final LikeClasses NOD;
2015-06-15 17:47:35 -07:00
public static LikeClasses[] values();
Code:
0: getstatic #2 // Field
$VALUES:[LLikeClasses;
3: invokevirtual #3 // Method
"[LLikeClasses;".clone:()Ljava/lang/Object;
...
2015-09-07 11:44:36 -06:00
*/