OnJava8-Examples/enums/NotClasses.java

41 lines
1.1 KiB
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// enums/NotClasses.java
2016-12-30 17:23:13 -08:00
// (c)2017 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.
2016-07-28 16:47:35 -06:00
// {javap -c LikeClasses}
2015-06-15 17:47:35 -07:00
enum LikeClasses {
WINKEN {
@Override
2015-11-03 12:00:44 -08:00
void behavior() { System.out.println("Behavior1"); }
2015-06-15 17:47:35 -07:00
},
BLINKEN {
@Override
2015-11-03 12:00:44 -08:00
void behavior() { System.out.println("Behavior2"); }
2015-06-15 17:47:35 -07:00
},
NOD {
@Override
2015-11-03 12:00:44 -08:00
void behavior() { 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;
public static final LikeClasses BLINKEN;
public static final LikeClasses NOD;
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
*/