Write a Java program to test if 10 appears as either the first or last element of an array of integers. The length of the array must be greater than or equal to 2
Sample Output:Test Data: array = 10, -20, 0, 30, 40, 60, 10
true
import java.lang.*; public class Exercise74 { public static void main(String[] args) { int[] num_array = {10, -20, 0, 30, 40, 60, 10}; System.out.println((num_array[0] == 10 || num_array[num_array.length-1] == 10)); } }
Sample Output:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer