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
Post a Comment