This is the python 2.7 code and its output
i = [0 for i in range(5)]
output:
[0, 0, 0, 0, 0]
what is the closest code to do this in Java?
This is the python 2.7 code and its output
i = [0 for i in range(5)]
output:
[0, 0, 0, 0, 0]
what is the closest code to do this in Java?
Here is the closest code:
public class Stackoverflow_03262019 {
public static void main(String[] args) {
int[] arr=new int[5];
Arrays.fill(arr,0);
Arrays.stream(arr).forEach(val-> System.out.println(val));
}
}
```
You can add any value instead of 0;