Java 9 SafeVarargs Annotation

By | June 27, 2021

@SafeVarargs annotation was introduced in Java7 and can only be applied on:

  • Final methods
  • Static methods
  • Constructors
  • This annotation is used to ensure that the method/Constructors does not perform unsafe operations on its varargs parameters.
  • From Java 9 onwards, it can also be used with private instance methods.

If you run as Java Application then it will give the below output: 

That’s all about Java 9 SafeVarargs Annotation

You May Also Like:

Java 9 Jshell Tutorial
Java 9 private Methods in Interfaces
Java 9 Try with Resource Enhancement
Java 9 Collection Factory Methods
Java 9 Stream API improvements

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *