Create a Java program to demonstrate the use of an interface for custom array manipulation
import java.util.Arrays; interface ArrayProcessor { void processArray(int[] array); } public class Main { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5}; ArrayProcessor doubler = array -> { for (int i = 0; i < array.length; i++) { array[i] *= 2; } }; doubler.processArray(numbers); System.out.println("Doubled Array : " + Arrays.toString(numbers)); } }
Doubled Array : [2, 4, 6, 8, 10]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions