【问题标题】:How to create Java method descriptions in Eclipse?如何在 Eclipse 中创建 Java 方法描述?
【发布时间】:2015-01-09 06:48:03
【问题描述】:

我对 Java 和 Eclipse IDE 完全陌生。我有 .NET 和 Visual Studio 的背景。在 VS 中,当我想为方法创建描述时,只需键入三个“/”字符,就会得到一个自动生成的注释模板,类似于下面的示例:

/// <summary>
/// This is my summary. Hope it is helpful. ;)
/// </summary>
/// <param name="item">Description of the item parameter.</param>
/// <returns></returns>
T Add(T item); 

因此,当有人使用我的方法时,IDE 会给他/她一个提示,该提示显示在方法名称的正上方。如何在 Eclipse 中实现这一点,并为我的 Java 方法提供描述?

【问题讨论】:

标签: java eclipse methods summary


【解决方案1】:

你应该使用 /** */ 表示法:

/** Comment */
private void method() {
}

它被称为 javadoc:http://en.wikipedia.org/wiki/Javadoc

【讨论】:

    【解决方案2】:
    /**
    * regular
    * @author John Doe
    * @param 
    * @return 
    * @since 01-01-2000
    * @version 1.0
    * @exception PersonNotFoundException  gevonden
    */
    

    【讨论】:

      【解决方案3】:

      Java:只需将/** 放在您的方法注释之前,就会生成自动。 ;)

      /**
       * This is my summary. Hope it is helpful. ;)
      */
      T Add(T item); 
      

      【讨论】:

        【解决方案4】:

        你可以选择方法、类、变量名并在eclipse IDE中输入ALT+SHIFT+J生成自动java描述如下:-

        /* (non-Javadoc)
         * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
         */
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            response.getWriter().append("Served at: ").append(request.getContextPath());
        }
        

        【讨论】:

          猜你喜欢
          • 2012-07-27
          • 1970-01-01
          • 2015-02-22
          • 2013-06-04
          • 1970-01-01
          • 2019-02-05
          • 2016-12-01
          • 2014-04-25
          • 2019-07-17
          相关资源
          最近更新 更多