Master Computers and Technology with Fun Quizzes & Brain Teasers!
In a program, write a method that accepts two arguments: an array of integersand a number n. The method should print all of the numbers in the arraythat are greater than the number n (in the order that they appear in thearray, each on their own line).In the same file, create a main method and call your function using the followingdata sets:The array {1, 5, 10, 2, 4, -3, 6} and the number 3.The array {10, 12, 15, 24} and the number 12.My code:public class LargerThanN{public static void print(int[] array,int n){for(int i=0; i{if (array[i]>n)System.out.println(array[i]);}System.out.println();}public static void main(String[] args){int[] array1 = {1,5,10,2,4,-3,6};int num1=3;print(array1,num1);int[] array2 = {10, 12, 15, 24};int num2 = 12;print(array2, num2);}}