2015-04-06 44 views
0

我有一个类动物 它有两个构造函数默认和参数化。现在我想注释默认构造函数,以便开发人员知道应该避免使用此方法,而应该使用参数化方法。注解方法与另一种方法的名称应该是可点击的

class Animal 
{ 

/** 
Discouraged- Use Animal(String name) instead. 
*/ 
public Animal() 
{} 


public Animal(String name) 
{...} 

} 

这里我有注解的默认构造函数,但IntelliSense不突出/点击的智能感知模块帕拉姆构造函数的名称。

另请分享一个文件,如果您有,所有“@”注释都以简单易懂的格式定义。

感谢

回答

0

我认为你需要使用Deprecated注释和Javadoc解释为什么。

class Animal 
{ 

/** 
* @deprecated 
* please don't use this method anymore 
*/ 
@Deprecated 
public Animal() 
{} 


public Animal(String name) 
{...} 

} 

有了这个注释,编译器会显示一个警告,不要使用该方法。

也许这个网站可以帮到你。

https://docs.oracle.com/javase/tutorial/java/annotations/

我希望这个信息可以帮助你。

祝你好运。

相关问题