Determine if a function is bijective
Your code looks nice. The only suggestion I have is to separate the bijection check out of the main, and make it, say, a static method. All in all, I had this in mind:

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class FunctionUtils {

    public static boolean isBijection(final Map&lt;Integer, Integer&gt; function) {
        final Set&lt;Integer&gt; domain = new HashSet&lt;&gt;(function.keySet());
        final Set&lt;Integer&gt; range  = new HashSet&lt;&gt;(function.values());
        return range.equals(domain);
    }

    public static void main(String[] args) {
        final Map&lt;Integer, Integer&gt; function = new HashMap&lt;&gt;();

        try (final Scanner in = new Scanner(System.in)) {
            final int n = in.nextInt();

            for (int i = 1; i &lt;= n; i++) {
                function.put(i, in.nextInt());
            }

            System.out.println("Bijection: " + isBijection(function));
        }
    }
}


Hope that helps.

Edit

Validating general bijections \$f \colon X \to Y\$ is not any harder:

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class FunctionUtils {

    public static &lt;E&gt; boolean isBijection(final Map&lt;E, E&gt; function) {
        return function.size() == new HashSet&lt;&gt;(function.values()).size();
    }

    public static void main(String[] args) {
        final Map&lt;Integer, Integer&gt; function = new HashMap&lt;&gt;();

        try (final Scanner in = new Scanner(System.in)) {
            final int n = in.nextInt();

            for (int i = 1; i &lt;= n; i++) {
                function.put(i, in.nextInt());
            }

            System.out.println("Function:  " + function);
            System.out.println("Bijection: " + isBijection(function));
        }
    }
}