'Declare static variables in inner non-static class

Why does this line:

static final Integer intValue = 1;

give a compiler error, while this line declared in the same way:

static final String strValue = "aaa";

does not.

The full code:

public class InnerClass {
    class NestedClass {
        static final String strValue = "aaa";
        static final Integer intValue = 1;
    }
}

Compile time error:

The field intValue cannot be declared static in a non-static inner type, unless initialized with a constant expression



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source