?? exceptionaltest.java
字號:
/**
@version 1.10 2000-06-03
@author Cay Horstmann
*/
import java.util.*;
public class ExceptionalTest
{
public static void main(String[] args)
{
int i = 0;
int ntry = 1000000;
Stack s = new Stack();
long s1;
long s2;
// test a stack for emptiness ntry times
System.out.println("Testing for empty stack");
s1 = new Date().getTime();
for (i = 0; i <= ntry; i++)
if (!s.empty()) s.pop();
s2 = new Date().getTime();
System.out.println((s2 - s1) + " milliseconds");
// pop an empty stack ntry times and catch the
// resulting exception
System.out.println("Catching EmptyStackException");
s1 = new Date().getTime();
for (i = 0; i <= ntry; i++)
{
try
{
s.pop();
}
catch(EmptyStackException e)
{
}
}
s2 = new Date().getTime();
System.out.println((s2 - s1) + " milliseconds");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -