0

在下面的代码中,assert 语句似乎被忽略了:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    runTest();
}

private void runTest() 
{
    int a = 0;
    int b = 1;
    Log.d("Test", "Start");     
    assert a == b : "assertion failed";
    Log.d("Test", "End");       
}
}

输出很简单:
04-30 12:48:51.078: D/Test(29964): Start
04-30 12:48:51.078: D/Test(29964): End

那里没有“断言失败”。

代码有什么问题?

4

0 回答 0