上下文
println(int priority,String tag,String msg)
我想知道'priority'参数。它可以采用以下值:Log.VERBOSE,LOG.WARN等,如Log类中所定义:
public static final int ASSERT = 7
public static final int DEBUG = 3
public static final int ERROR = 6
public static final int INFO = 4
public static final int VERBOSE = 2
public static final int WARN = 5
问题
为什么不能简单地使用直的整数值并且必须使用定义的public static final int value枚举?
示例:
Log.println(5,"HI","HI"); //-> can`t
Log.println(2,"HI","HI"); //-> can`t
Log.println(Log.VERBOSE,"HI","HI");// -> can
Log.println(Log.WARN,"HI","HI") //-> can
......和其他例子:
public class MainActivity extends AppCompatActivity {
public static final int A = 7;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.println(A,"HI","HI"); // ->can`t
Log.println(2,"HI","HI"); // ->can`t
Log.println(Log.VERBOSE,"HI","HI"); // ->can
}
为什么你不能写Log.println(2,"HI","HI")
这些都是整数...