TargetApi is one of the Annotation type, not variable.
It implements java.lang.annotation.Annotation interface like any other annotations.
There are many annotations (types) in Java.
They are used by Java compiler like Directives or by Javadoc for documentation or Android Lint for API version safety.
TargetApi is used by Lint only.
And the assigned value can be numeric literal or static(not instance) variable. Because when checking the code, Lint can know about it.
“Lint should treat this type as targeting a given API level, no matter what the project target is.”
Same name of classes or methods can be exist in different versions of SDK and their implementation can be different.
In this case if we use them without TaregetApi and Lint checking, our code can be crashed when running(such as “unresolved symbol”).
So it would be better to use TargetApi and Lint, I think.
Enjoy Android Programming!