Following syntax is used to define an array.
Syntax
var arrayName = new dataType[]{}
Example
var primes = new int[] {2, 3, 5, 7}
jshell> var primes = new int[] {2, 3, 5, 7}
primes ==> int[4] { 2, 3, 5, 7 }
jshell> primes[0]
$2 ==> 2
jshell> primes[2]
$3 ==> 5
jshell>
No comments:
Post a Comment