1 / 8

Advanced Java online training

https://www.gangboard.com/app-programming-scripting-training/core-java-training<br>

dhekitha
Download Presentation

Advanced Java online training

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Array https://www.gangboard.com/app-programming-scripting-training/core-java-training

  2. Java Array • Normally, an array is a collection of similar type of elements which have a contiguous memory location. • Java arrayis an object which contains elements of a similar data type. Additionally, The elements of an array are stored in a contiguous memory location. • It is a data structure where we store similar elements. We can store only a fixed set of elements in a Java array.

  3. Features of Array • Arrays are objects • They can even hold the reference variables of other objects • They are created during runtime • They are dynamic, created on the heap • The Array length is fixed

  4. Array Declaration • dataType[] arrayName; • dataType can be aprimitive data type like: int, char, Double, byte etc. or an object (will be discussed in later chapters). • arrayName is an identifier.

  5. Advantages & Disadvantages Advantages: • Code Optimization: It makes the code optimized, we can retrieve or sort the data efficiently. • Random access: We can get any data located at an index position. Disadvantages: • 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.

  6. Types of Array in java There are two types of array. • Single Dimensional Array • Multidimensional Array

  7. One-dimensional array One-dimensional array in Java programmingis an array with a bunch of values having been declared with a single index. • Syntax to Declare Array in Java: dataType[] arr; (or)   dataType []arr; (or)   dataTypearr[];

  8. Multidimensional Arrays Multidimensional Arrays can be defined in simple words as array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order). • Syntax to Declare Array in Java: dataType[][] arrayRefVar; (or)   dataType [][]arrayRefVar; (or)   dataTypearrayRefVar[][]; (or)   dataType []arrayRefVar[]; 

More Related