2012-02-06 67 views
0

我必须实现一些功能类。这些函数必须返回一些错误代码,我通常用来声明一个带有错误代码的公共枚举并且适用于我(例如在c#中),但我已经读过枚举在Android(性能)中不太好,所以你认为这个代码?Android Java:这是一个好方法,而不是枚举?

public class myClass_1 
{ 
public final class myErrorCodes 
{ 
    public static final int ERROR_1 = 0x01; 
    public static final int ERROR_2 = 0x02; 
    public static final int ERROR_3 = 0x03; 
    public static final int ERROR_4 = 0x04; 
    public static final int ERROR_5 = 0x05; 
    public static final int ERROR_6 = 0x06; 
} 

public int Function_1(int a,int b) 
{ 
    // do something here... 

    return myErrorCodes.ERROR_1; 
} 
} 
+4

不是很确定枚举是坏的(再),http://stackoverflow.com/questions/5143256/why-was-avoid -enums-where-you-only-need-ints-removed-from-androids-performanc – 2012-02-06 12:50:53

回答

0

没有使用枚举now任何问题。所以,如果你愿意,你可以使用它。

与整数代码会稍微快一点的工作 - 但你会看到韦迪它:)

+0

好吧,是的,我只是看到它! thx的答案! – skabo 2012-02-06 20:39:09