Java program to display the elements in an array

PROGRAM 1:

package com.company;
import java.io.*;
public class Main {

public static void main(String[] args) {
int[] num ={1,5,6,77,88};
for(int i=0;i<num.length;i++)
{System.out.println(num[i]);
}}}

PROGRAM 2:
package com.company;
import java.io.*;
public class Main {
public static void main(String[] args) {
int[] num ={1,5,6,77,88};
for(int i:num)
{
System.out.println(i);
}}}

OUTPUT:
Output for both Progarm 1 and Program 2 are same as below
1
2
6
77
88

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.