Stay organized with collections
Save and categorize content based on your preferences.
SuppressWarnings
public
abstract
@interface
SuppressWarnings
implements
Annotation
java.lang.SuppressWarnings
|
Indicates that the named compiler warnings should be suppressed in the
annotated element (and in all program elements contained in the annotated
element). Note that the set of warnings suppressed in a given element is
a superset of the warnings suppressed in all containing elements. For
example, if you annotate a class to suppress one warning and annotate a
method to suppress another, both warnings will be suppressed in the method.
As a matter of style, programmers should always use this annotation
on the most deeply nested element where it is effective. If you want to
suppress a warning in a particular method, you should annotate that
method rather than its class.
Summary
Public methods |
String[]
|
value()
The set of warnings that are to be suppressed by the compiler in the
annotated element.
|
Public methods
value
public String[] value ()
The set of warnings that are to be suppressed by the compiler in the
annotated element. Duplicate names are permitted. The second and
successive occurrences of a name are ignored. The presence of
unrecognized warning names is not an error: Compilers must
ignore any warning names they do not recognize. They are, however,
free to emit a warning if an annotation contains an unrecognized
warning name.
The string "unchecked"
is used to suppress
unchecked warnings. Compiler vendors should document the
additional warning names they support in conjunction with this
annotation type. They are encouraged to cooperate to ensure
that the same names work across multiple compilers.
Returns |
String[] |
the set of warnings to be suppressed |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# SuppressWarnings\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nSuppressWarnings\n================\n\n\n`\npublic\n\n\nabstract\n@interface\nSuppressWarnings\n`\n\n\n`\n\n\nimplements\n\n`[Annotation](/reference/java/lang/annotation/Annotation)`\n\n\n`\n\n|----------------------------|\n| java.lang.SuppressWarnings |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nIndicates that the named compiler warnings should be suppressed in the\nannotated element (and in all program elements contained in the annotated\nelement). Note that the set of warnings suppressed in a given element is\na superset of the warnings suppressed in all containing elements. For\nexample, if you annotate a class to suppress one warning and annotate a\nmethod to suppress another, both warnings will be suppressed in the method.\n\nAs a matter of style, programmers should always use this annotation\non the most deeply nested element where it is effective. If you want to\nsuppress a warning in a particular method, you should annotate that\nmethod rather than its class.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` `[String[]](/reference/java/lang/String) | ` `[value](/reference/java/lang/SuppressWarnings#value())`() ` The set of warnings that are to be suppressed by the compiler in the annotated element. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.lang.annotation.Annotation](/reference/java/lang/annotation/Annotation)` ` |-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Class](/reference/java/lang/Class)`\u003c? extends `[Annotation](/reference/java/lang/annotation/Annotation)`\u003e` | ` `[annotationType](/reference/java/lang/annotation/Annotation#annotationType())`() ` Returns the annotation interface of this annotation. | | ` abstract boolean` | ` `[equals](/reference/java/lang/annotation/Annotation#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Returns true if the specified object represents an annotation that is logically equivalent to this one. | | ` abstract int` | ` `[hashCode](/reference/java/lang/annotation/Annotation#hashCode())`() ` Returns the hash code of this annotation. | | ` abstract `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/annotation/Annotation#toString())`() ` Returns a string representation of this annotation. | ||\n\nPublic methods\n--------------\n\n### value\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic String[] value ()\n```\n\nThe set of warnings that are to be suppressed by the compiler in the\nannotated element. Duplicate names are permitted. The second and\nsuccessive occurrences of a name are ignored. The presence of\nunrecognized warning names is *not* an error: Compilers must\nignore any warning names they do not recognize. They are, however,\nfree to emit a warning if an annotation contains an unrecognized\nwarning name.\n\nThe string `\"unchecked\"` is used to suppress\nunchecked warnings. Compiler vendors should document the\nadditional warning names they support in conjunction with this\nannotation type. They are encouraged to cooperate to ensure\nthat the same names work across multiple compilers.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------------|---------------------------------------------|\n| [String[]](/reference/java/lang/String) | the set of warnings to be suppressed \u003cbr /\u003e |"]]