Update "Another way to create an Array:" section (#19852)

* Update "Another way to create an Array:" section

Add another way to declare an array.

* Update 'Another way to create an Array' section, Add 'Declaring array literal' section.
pull/30781/head
Smruti Ranjan Rana 2018-10-28 08:49:11 +05:30 committed by Manish Giri
parent 75d856fa26
commit 24392e05d0
1 changed files with 12 additions and 0 deletions

View File

@ -62,6 +62,18 @@ double[] list = new double[4];
that are used to represent arrays in two different ways.
```
## Declaring array literal
```java
dataType[] arrayName = new dataType[] {value_0, value_1, ..., value_k};
```
## Code snippets of above syntax:
```java
int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 };
```
## Accessing Arrays:
```java
arrayName[index]; // gives you the value at the specified index