Saturday 2 June 2018

What Is Array In Java Explained With Examples | Java Technocrat [Hindi]




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





Source Code

--------------------------------------



public class Data

{

public static void main(String args[])

{

// step -1

int arr[];

String str[];



//sterp-2



arr = new int[3];

str = new String[3];



System.out.println("\nSee the array elements after construction\n");

for(int i =0;i<3;i++)

{

System.out.println(arr[i]);

}



for(int i =0;i<3;i++)

{

System.out.println(str[i]);

}



// step-3



arr[0]=12;

arr[1]=15;

arr[2]=7;



str[0]="Red";

str[1]="Green";

str[2]="Blue";

System.out.println("\nSee the elements after initialistaion\n");



for(int i =0;i<3;i++)

{

System.out.println(arr[i]);

}



for(int i =0;i<3;i++)

{

System.out.println(str[i]);

}

System.out.println(arr[5]); // ArrayIndexOutOfBoundsException

}

}







-----------------------------------------------------------------------------------------

No comments:

Post a Comment