Write a class with name ArrayDemo . This class has an array which should be initialized by user as given below. write a function with name display in this class.Call this display function in main function. [4 marks]
-1 4 1 6 3 8 5 10 7 12
public class ArrayDemo
{
public static void display(int[] numbers)
{
for(int number:numbers)
System.out.print(number+" ");
}
public static void main(String[] args)
{
int[] numbers = {-1 ,4, 1, 6, 3, 8, 5 ,10, 7 ,12};
display(numbers);
}
}
Comments
Leave a comment