How do you initialize an array in Java?

Question:How do you initialize an array in Java?

1.int[] arr = (1,2,3,4,5);

2.int arr = {1,2,3,4,5};

3.int[] arr = new int[]{1,2,3,4,5};

4.int arr = new int(5);


Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!