Write a program that declares and initializes an int array with length 5. Then, insert the numbers 1 through 5, in that order, into the array in whichever way you like (you can insert them in the initialization step too). Try to think of and code multiple ways to solve this problem!
top of page
bottom of page
class Main { public static void main(String[] args) { int [] myarray = {1, 2, 3, 4, 5}; } } and class Main { public static void main(String[] args) { int [] myarray = new int [5]; myarray [0] = 1; myarray [1] = 2; myarray [2] = 3; myarray [3] = 4; myarray [4] = 5; } }