How to Initialize int or Integer array in declaration?

Following excerpt show How you can Initialize int or Integer array in its declaration.

Source code

public class InitializeIntArrayExample < public static void main(String[] args) < /* Declare and Initialize int Array */ int intArray[] = ; System.out.println("Print value of int[]"); /* Print value of array */ for (int i : intArray) < System.out.println(i); >/** * Declare and Initialize Integer Array. * Integer can hold `null` values. */ Integer integerArray[] = ; System.out.println("Print value of Integer[]"); for (Integer i : integerArray) < System.out.println(i); >> >

Output
Print value of int[] 10 20 30 Print value of Integer[] 10 20 null

Vicky Thakor

0 comments :

Subscribe to: Post Comments ( Atom )

Social Media

Interesting Posts

URL shortening using tinyURL- An API for Java / JSP / Servlet - Unofficial API

How to iterate over stream and increment index value in Lambda Expression?

How to create mobile tracking application?