JavaでのgetCause()メソッドの重要性?
public Throwable getCause()
public class GetCauseMethodTest {
public static void main(String[] args) throws Exception {
try {
myException();
} catch(Exception e) {
System.out.println("Cause = " + e.getCause());
}
}
public static void myException() throws Exception {
int arr[] = {1, 3, 5};
try {
System.out.println(arr[8]);
} catch(ArrayIndexOutOfBoundsException aiobe) {
Exception e = new Exception();
throw(Exception); // throwing the exception to be caught by catch block in main()
e.initCause(aiobe); // supplies the cause to getCause()
}
}
} 出力
Cause = java.lang.ArrayIndexOutOfBoundsException: 8
-
Java 9でのdestroyForcibly()メソッドの重要性?
destroyForcibly() メソッドを使用してプロセスを強制終了できます 。プロセスが終了またはフリーズした場合に必要になります。たとえば、 isAlive() destroyForcibly()の後にメソッドはtrueを返します と呼ばれます。 destroyForcibly() メソッドは、終了が正常に要求された場合はtrueを返し、それ以外の場合はfalseを返します。 構文 boolean destroyForcibly() 以下の例では、メモ帳を起動できます。 アプリケーションであり、 destroyForcibly()の後に終了します メソッドが呼び出されました。 例
-
JavaでのCursorクラスの重要性は何ですか?
カーソル オブジェクトのサブクラスです クラスであり、ポイントまたはインジケーターとして定義できます。 画面上。 カーソル ユーザーがマウスで操作するシステムからの入力を選択するために使用されます 。 カーソルで使用できるさまざまな種類のカーソル クラスはDEFAULT_CURSOR、CROSSHAIR_CURSOR、HAND_CURSOR、TEXT_CURSOR、WAIT_CURSOR Cursorクラスの重要なメソッドは、 getDefaultCursor()、getName()、getPredefinedCursor()、getSystemCustomCursor()です。 およびge