Deprecate in Java 1.6
问题 In Java 1.5, to deprecate a method you would: @Deprecated int foo(int bar) { } Compiling this in Java 1.6 results in the following: Syntax error, annotations are only available if source level is 1.5 Any ideas? 回答1: You have to tell the compiler to use 1.6: javac -source 1.6 Or equivalent for your IDE/build system (as others have suggested). 回答2: First, its @Deprecated , and second - double-check if you are really compiling with Java 1.6. What are you using? javac? Eclipse? If using javac,