Array In java - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Advantage

Array In java

Array in java 

Generally In array is collection of similar type of elements which have a contiguous memory
located.

Array in java is index based , the first element of the array is stored at 0th index
 2nd element is stored on 1st index and so on .


Java array

Advantage 

* Code  Optimization : it make the code optimized, we can retrieve or sort   the data
   efficiently.
* Random access: We can get any data using the index position.


Disadvantages of array 
* Size limit:  We can store only the fixed size of elements in the array ,It doesn't grow
its size at runtime. To solve this problem, collection framework is used in java which grows automatically.


  Type Of Array 
* Single Dimensional Array
* Multidimensional Array


1. Declaration an array.

 dataType[] arr; //and
 dataType[]arr;//and
dataType arr[];

Instantiation of array

arrayvar=new dataType[size];

For Example :
class TestArray
{
  public static void main(String[]args)
{
  int [x]=new int[5]; // there is declaration and instantition
  x[0]=10;
  x[1]=20;
  x[2]=30;
  x[3]=40;
  x[4]=50;
 
for(int i=0;i<x.length;i++)
{
  System.out.prinltn(x[i]);
}
  }
}

 Output :
  10
  20
  30
  40
  50










About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.