私はいくつかのクラスを関数で実装する必要があります。これらの関数はいくつかのエラーコードを返す必要があります。私は通常、エラーコードで公開列挙型を宣言するために使用し、それは私のために働きます(例えばC#で)が、enumはAndroid(パフォーマンス)このコードについてどう思いますか?Android Java:これはenumsの代わりに良い方法ですか?
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;
}
}
列挙型は(もはや)悪いですので、わからない、http://stackoverflow.com/questions/5143256/why-was-avoid -enums-where-you-only-need-ints-removed-from-androids-performanc –