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代码:
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代码:
 1 final class DayType {
final class DayType {
2
3 public static final DayType WORKING = new DayType();
    public static final DayType WORKING = new DayType();
4
5 public static final DayType WEEKEND = new DayType();
    public static final DayType WEEKEND = new DayType();
6
7 public static final DayType HOLIDAY = new DayType();
    public static final DayType HOLIDAY = new DayType();
8 }
}
9
10 public class MyCalendar {
public class MyCalendar {
11
12 public DayType getDayType() {
    public DayType getDayType() {
13 return DayType.WEEKEND;
        return DayType.WEEKEND;
14 }
    }
15
16 }
}
17
 final class DayType {
final class DayType {2

3
 public static final DayType WORKING = new DayType();
    public static final DayType WORKING = new DayType();4

5
 public static final DayType WEEKEND = new DayType();
    public static final DayType WEEKEND = new DayType();6

7
 public static final DayType HOLIDAY = new DayType();
    public static final DayType HOLIDAY = new DayType();8
 }
}9

10
 public class MyCalendar {
public class MyCalendar {11

12
 public DayType getDayType() {
    public DayType getDayType() {13
 return DayType.WEEKEND;
        return DayType.WEEKEND;14
 }
    }15

16
 }
}17

 
                    
                     
                    
                 
                    
                 
 
        

 
     
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号