import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
         int[] arr={2,7,11,15};
        Map<Integer,Integer> m=new HashMap<>();
        int target=9;
        for(int i=0;i<4;i++){
            int diff=target-arr[i];
            if(m.containsKey(diff)){
                System.out.println(m.get(diff)+" "+i);
            }
            m.put(arr[i],i);
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: