Question:
How to declare array in Java?
Code:
public class DeclareArrays { public static void main(String[] args) { // primitive types: int[] intArray1 = new int[3]; int[] intArray2 = {1,2,3}; int[] intArray3 = new int[]{1,2,3}; // strings String[] stringArray1 = new String[3]; String[] stringArray2 = {"a","b","c"}; String[] stringArray3 = new String[]{"a","b","c"}; } }