From 24392e05d0cf7999aec1c4c624095728791596b5 Mon Sep 17 00:00:00 2001 From: Smruti Ranjan Rana Date: Sun, 28 Oct 2018 08:49:11 +0530 Subject: [PATCH] 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. --- guide/english/java/arrays/index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/guide/english/java/arrays/index.md b/guide/english/java/arrays/index.md index 9e62e3970e..cc94e19d93 100644 --- a/guide/english/java/arrays/index.md +++ b/guide/english/java/arrays/index.md @@ -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