java注释 param,我在为主要方法的@param编写Javadoc注释时遇到问题

这篇博客讨论了Java编程中@param注释的重要性。作者在编写一个RectangleIntersection类时遇到了困难,尤其是对于方法参数的注释。文章指出@param注释必须对应方法参数,并提供了正确的使用示例。主要内容包括如何正确地为main方法的参数添加注释,以及代码示例来解释@param的用法。
摘要由CSDN通过智能技术生成

I'm very new to Java and taking an online course with little feedback.

I think I have the program completed okay, but my prof requires comments to be done and I've had no guidance on them. My biggest area seems to be the @param comments. I've tried putting different things in there but nothing is correct. Can anyone tell me what I'm doing wrong? Give me a link for easy to read info on @param comments.

Here's my code:

/**

*

*/

package edu.westga.cs6311.rectangles;

import java.awt.Rectangle;

/**

* The RectangleIntersection class creates two rectangles that overlap (making a third rectangle) with a fourth rectangle not overlapping.

* @author Tanya Fairbanks

* @version 9/8/2013

*/

public class RectangleIntersection {

/**

* The main method is where the rectangles are created.

* @param rectangle1 the original rectangle

* @param rectangle2 the overlapping rectangle

* @param rectangle3 the rectangle made from intersecting rectangle1 & rectangle2

* @param rectangle4 the rectangle made that does not intersect with rectangle3

*/

public static void main(String[] args) {

// make 2 overlapping rectangles

Rectangle rectangle1 = new Rectangle(3, 12, 5, 3);

Rectangle rectangle2 = new Rectangle(5, 11, 6, 4);

System.out.println(rectangle1);

System.out.println(rectangle2);

//intersection of rectangles 1 & 2 is rectangle3

Rectangle rectangle3 = rectangle1.intersection(rectangle2);

System.out.println(rectangle3);

//figure the area of rectangle3

double width = rectangle3.getWidth();

double height = rectangle3.getHeight();

double area = width * height;

System.out.println("Expected area: 9.0 ");

System.out.println("Calculated area: " + area);

//create 4th rectangle that doesn't overlap 3rd

Rectangle rectangle4 = new Rectangle(1, 15, 13, 12);

System.out.println(rectangle4);

//find intersection of 3rd and 4th rectangles

Rectangle theIntersection = rectangle3.intersection(rectangle4);

System.out.println(theIntersection);

//print expected area and calculated area of theIntersection

double width2 = theIntersection.getWidth();

double height2 = theIntersection.getHeight();

double area2 = width2 * height2;

System.out.println("Expected area: 0.0");

System.out.println("Calculated area: " + area2);

}

}

解决方案

@param must match an argument of the method being documented, e.g:

/**

* A method that adds x and y.

* @param x The first operand

* @param y The second operand

*/

public int add(int x, int y) {

return x+y;

}

In your case, you want to document program command-line arguments. Use plain javadocs to do that.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值