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!
To see this working, head to your live site.
Search
kevinzhao183
Feb 7
Intro to Java 2/6/21 Homework
Intro to Java 2/6/21 Homework
1 comment
0
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; } }