Posts

Showing posts from June, 2017

Java multidimensional array

Image
In Java , a multidimensional array data is stored in row and column based index. In the Java programming language, a multidimensional array is an array whose components are themselves arrays.  Example :         class TwoDArrayDemo{             public static void main(String args[]){                 //declaring and initializing 2D array                  int arr[][] ={{5,10},{15,20}};               //printing 2D array               for(int i=0;i<2;i++){   // Row                      f...

Java Arrays

Image
An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. Each item in an array is called an element , and each element is accessed by its numerical index . Types Of Array : Single Dimensional Array Multidimensional Array Array Declaring :    int[] anArray ; Creating an Array :     anArray = new int[10];  // new is an operator to create memory   Initializing an Array : // initialize first element     anArray[0] = 10; // initialize second element   anArray[1] = 15; ... ... // and last element   anArray[9] = 200;   Accessing an Array : System.out.println(" Element 1 at index 0: " + anArray[0] );   Output :    Element 1 at index 0 : 10   Example :     class ArrayDemo{       public static void ma...