Non-Correct Syntax Error During Java Compile on DSA sub-array sum

Hello, can some one confirm that while using Maps, the compiler throws an error while the syntax is completely correct. Also I though the IDE uses java 8 but it throws java 6 errors.

Main.java:6: error: illegal start of type
import java.util.Map;
^
Main.java:6: error: <identifier> expected
import java.util.Map;
                    ^
Main.java:7: error: illegal start of type
import java.util.HashMap;
^

All import statements must come before any class or interface declarations.


import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        map.put("A", 1);
        System.out.println(map.get("A"));
    }
}