How to Initialize long or Long array in declaration?
UPDATED: 25 October 2015
Tags:
Array
Following excerpt show How you can Initialize long or Long array in its declaration.
Source code
Output
References
How to Initialize int or Integer array in declaration?
How to Initialize float or Float array in declaration?
How to Initialize double or Double array in declaration?
How to Initialize boolean or Boolean array in declaration?
Source code
public class InitializeLongArrayExample { public static void main(String[] args) { /* Declare and Initialize long Array */ long longArray1[] = {10L, 20L, 30L}; System.out.println("Print value of long[]"); /* Print value of array */ for (long l : longArray1) { System.out.println(l); } /** * Declare and Initialize Long Array. * Long can hold `null` values. */ Long longArray2[] = {10L, 20L, null}; System.out.println("Print value of Long[]"); /* Print value of array */ for (Long l : longArray2) { System.out.println(l); } } }
Output
Print value of long[] 10 20 30 Print value of Long[] 10 20 null
References
How to Initialize int or Integer array in declaration?
How to Initialize float or Float array in declaration?
How to Initialize double or Double array in declaration?
How to Initialize boolean or Boolean array in declaration?
Tags:
Array
0 comments :