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

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

Automation using selenium and python/java interview question to order a product in e commerce website.