Delphi中Enum在Java 1.4实现

delphi代码:

DayType =(dtWorking,dtWeekend,dtHoliday);

  MyCalendar = class
  private
          function GetCurrentDayType:DayType ;
  public
          property CurrentDayType:DayType read GetCurrentDayType;
  end;

function MyCalendar.GetCurrentDayType:DayType;
begin
    result := dtWorking;
end;

java代码:

 1final class DayType {
 2
 3    public static final DayType WORKING = new DayType();
 4
 5    public static final DayType WEEKEND = new DayType();
 6
 7    public static final DayType HOLIDAY = new DayType();
 8}

 9
10public class MyCalendar {
11
12    public DayType getDayType() {
13        return DayType.WEEKEND;
14    }

15
16}

17
原文地址:https://www.cnblogs.com/jssy/p/408390.html