The following Java program determines whether it is an Array of Specific Elements or not.

In this problem, we have an array of integers. We need to find whether the array comprises of only the elements which are input by the user. For example, suppose we have an array = (1,4,4,4,1,1,4). Whereas the numbers that we are looking for in the array are 1 and 4. Hence, the output should be true.

Another example, array = (1,1,1). So the output should be true.

Whereas, suppose the array is (1,1,4,2,4,1). Now the output should be false.

The following code shows the java program to find the Array of Specific Elements.

``````public class Exercise11
{
public static void main(String[] args) {
int[] myarray={1, 4, 1, 4};
//  int[] myarray={1, 4, 2, 4};
// int[] myarray={1, 1};
//  int[] myarray={3, 1, 4, 8, 9, 12, 17, 5, 2, 10, 6, 121, 89, 10};
System.out.println("Array Elements...");
for(int i=0;i<myarray.length;i++)
{
System.out.print(myarray[i]+"\t");
}
boolean t=true;
for(int i=0;i<myarray.length;i++)
{
int x=myarray[i];
if((x!=1) && (x!=4))
{
t=false;
}
}
System.out.println("\n"+t);
}
}``````

Output