My Java ENUM CLASS

xiaoxiao2021-03-06  140

public class Direction {public static final Direction East = new Direction ( "East"); public static final Direction West = new Direction ( "West"); public static final Direction North = new Direction ( "North"); public static final Direction South = New Direction ("South");

Private final string dirstring; private direction (string name) {dirstring = name;}

Public string toString () {return Dirstring;

Public static direction parse (String DS) {Try {Direction Ret = NULL; Field [] fs = Direction.class.Getfields (); for (int i = 0; i

} Return Ret;} catch (exception ex) {throw new runtimeException (DS "is a invalid direction enum string.");}}}

转载请注明原文地址:https://www.9cbs.com/read-127937.html

New Post(0)