[Assorted-commits] SF.net SVN: assorted:[1621] sandbox/trunk/src/java/Enums.java
Brought to you by:
yangzhang
From: <yan...@us...> - 2010-04-15 20:57:22
|
Revision: 1621 http://assorted.svn.sourceforge.net/assorted/?rev=1621&view=rev Author: yangzhang Date: 2010-04-15 20:57:15 +0000 (Thu, 15 Apr 2010) Log Message: ----------- playing with enums and erasure Added Paths: ----------- sandbox/trunk/src/java/Enums.java Added: sandbox/trunk/src/java/Enums.java =================================================================== --- sandbox/trunk/src/java/Enums.java (rev 0) +++ sandbox/trunk/src/java/Enums.java 2010-04-15 20:57:15 UTC (rev 1621) @@ -0,0 +1,24 @@ +package com.relationalcloud.main; + +public class Sandbox { + + public static class Msg<E extends Enum<E>> { + int ordinal; + + E type() { + return null; + // Can't do the following due to erasure. + // return E.values()[ordinal]; + } + } + + enum PingPongMsg { + PING, PONG + } + + public static void main(String[] args) { + Msg<PingPongMsg> msg = new Msg<PingPongMsg>(); + msg.type(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |