Click here to watch in Youtube :
https://www.youtube.com/watch?v=tq68sG3ydMc&list=UUhwKlOVR041tngjerWxVccw
ArrayDemo.java
To Download ArrayDemoOutOfBoundApp Project Click the below linkhttps://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)
https://sites.google.com/site/javaee4321/java/ArrayDemoOutOfBoundApp.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment