思远(BonaShen)博客

朋友们,我有了新了家,就在http://www.bonashen.com

导航

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

posted on 2006-05-24 22:07  Bona shen  阅读(527)  评论(0编辑  收藏  举报