Monday, 26 October 2015

Java Tutorial : Java Array (ArrayIndexOutOfBoundsException)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=tq68sG3ydMc&list=UUhwKlOVR041tngjerWxVccw

ArrayDemo.java
class ArrayDemo
{
    public static void main(String[] args)
    {
        // declares an array of bytes and allocates memory for 2 bytes
        byte[] byteArray = new byte[2];

        System.out.println("Length of the Array : " + byteArray.length);

        // initialize first element
        byteArray[0] = 1;
        // initialize second element
        byteArray[1] = 2;
        // and so forth
        byteArray[2] = 3;
        byteArray[3] = 4;

    }
}
Output
Length of the Array : 2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
    at ArrayDemo.main(ArrayDemo.java:15)
To Download ArrayDemoOutOfBoundApp Project Click the below link
https://sites.google.com/site/javaee4321/java/ArrayDemoOutOfBoundApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment