how do I create an array in java using a for loop? Solution import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be \"Main\" only if the class is public. */ class Ideone { public static void main (String[] args) { // your code goes here int[] nums = new int[10]; // Fill it with numbers using a for-loop for (int i = 0; i < nums.length; i++){ nums[i] = i + 1; } //print array for (int i = 0; i < nums.length; i++) { System.out.println(nums[i] + \" \"); } } } .