⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 array_3.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
字号:
// Test to make sure null arrays throw the right execptionpublic class Array_3{  static Object foo ()  {    return null;  }  static int[] bar ()  {    return null;  }  static int baz ()  {    int[] x = (int[])null;    int nn = x.length;    return 5;  }  public static void main(String args[])  {    boolean ok = false;    int nn = 0;    try      {	int[] x = (int[])foo();	nn = x.length;      }    catch (NullPointerException _)      {	ok = true;      }    if (!ok)      throw new RuntimeException("test failed:1");    ok = false;    try      {	int[] x = bar();	nn = x.length;      }    catch (NullPointerException _)      {	ok = true;      }    if (!ok)      throw new RuntimeException("test failed:2");    ok = false;    try      {	int[] x = bar();	nn = x[0];      }    catch (NullPointerException _)      {	ok = true;      }    if (!ok || nn != 0)      throw new RuntimeException("test failed:3");    ok = false;    try      {	int[] x = (int[])null;	nn = x.length;      }    catch (NullPointerException _)      {	ok = true;      }    if (!ok)      throw new RuntimeException("test failed:4");    ok = false;    try      {	nn = baz ();      }    catch (NullPointerException _)      {	ok = true;      }    if (!ok)      throw new RuntimeException("test failed:5");  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -