Here you can find the source of printArrayInfo(int[] array)
public static void printArrayInfo(int[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static void printArrayInfo(int[] array) { try {//from www. ja v a 2 s .c o m System.out.println("The array lenght is: " + array.length); System.out.println("Some text!!!!!!!!!!!!"); System.out.println("The third element is: " + array[2]); } catch (NullPointerException e) { System.out.println("The array must not be null!"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("The array must has at least 3 elements"); } //THIS IS THE RIGHT WAY TO HANDLE THIS PROBLEMS !!! // if(array == null) { // System.out.println("The array must not be null!"); // return; // } // System.out.println("The array lenght is: " + array.length); // System.out.println("Some text!!!!!!!!!!!!"); // if(array.length < 3) { // System.out.println("The array must has at least 3 elements"); // } // System.out.println("The third element is: " + array[2]); } }