How to declare and initialize int array in Java

1 Answer

0 votes
import java.util.Arrays;

public class MyClass {
    public static void main(String args[]) {
        int[] array = { 10, 20, 30, 234, 8493, 5, 900};

        for (int n : array) {
            System.out.println(n);
        }
    }
}



 
/*
run:
 
10
20
30
234
8493
5
900
 
*/

 



answered Oct 4, 2021 by avibootz

Related questions

2 answers 197 views
6 answers 259 views
1 answer 127 views
1 answer 178 views
...