Display numbers 1 to 10 using array

PROGRAM:

public class MainClass

{ public static void main(String[] args) throws IOException { int[] list = new int[10]; // Fill the array for (int i = 0; i < list.length; i++) list[i] = i+1; // Display the contents of the array for (int i = 0; i < list.length; i++) System.out.println(list[i]); } OUTPUT:
1
2
3
4
5
6
7
8
9
10

Comments

Popular posts from this blog

Java Program to create a large array and copy its values equally to two small arrays and display the second array only

Python program to sum up the Salary when the Name and Age matches with subsequent rows.