Java Array Print printArrayInfo(int[] array)

Here you can find the source of printArrayInfo(int[] array)

Description

print Array Info

License

Open Source License

Declaration

public static void printArrayInfo(int[] array) 

Method Source Code

//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]);

    }
}

Related

  1. printArray(T[] arr)
  2. printArray(T[] array)
  3. printArray(T[] array)
  4. printArrayElements(T[] array)
  5. printArrayFrom(int[] array, int start)
  6. printArrayNoSpaces(int[] nums)
  7. printArrayRec(int[] workArray, int idx)
  8. printArrayToString(Object[] array)
  9. printErrInvocationString(String cls, String[] args)