类的文档中没有变量

时间:2013-04-17 21:40:50

标签: java javadoc

我有简单的课程

import java.io.PrintStream;
/**
* Calculate roots of polynom ax^2 + bx + c = 0
* @author XXXX aka XXX
* @version 1.0 17.04.2013
*/
public class Lab1_1 {

/** 
* quadratic coefficient 
*/
private float a;
/** 
* linear coefficient 
*/
private float b;
/** 
* free term 
*/
private float c;

/**
*
* Constructor Lab1_1
*
* @param a {@link Lab1_1#a}
* @param b {@link Lab1_1#b}
* @param c {@link Lab1_1#c}
*/
public Lab1_1(float a, float b, float c) {
    this.a = a;
    this.b = b;
    this.c = c;
}

/**
* Calculate roots of quadratic equation
*
* @return returns string representation of roots of the polynom
* @throws ArithmeticException in case of complex number result
*/
public String calculate() {
    float discriminant = b * b - 4 * a * c;
    if (discriminant > 0) {
        double result1 = (-b + Math.sqrt(discriminant)) / (2 * a);
        double result2 = (-b - Math.sqrt(discriminant)) / (2 * a);
        return "x1 = " + result1 + ";" + "x2 = " + result2;
    } else if (discriminant == 0) { 
        double result = -b / (2 * a);
        return "x1 = " + result + ";" + "x2 = " + result;
    } else throw new ArithmeticException("Discriminant is less than zero! The result is a complex number!");

}

public static void main(String[] args) {
    try{
        if (args.length < 3) {
            new PrintStream(System.out, true, "UTF-8").println("Number of input arguments is less than 3");
            return;
        }
        try{
            new PrintStream(System.out, true, "UTF-8").
                println(
                    new Lab1_1(Float.parseFloat(args[0]),Float.parseFloat(args[1]),Float.parseFloat(args[2])).
                    calculate());
        }catch(ArithmeticException e) { 
            System.out.println(e.getMessage()); 
        }
    }
    catch(Exception e) { e.printStackTrace(); }
}
}

但是当我在Lab1_1 html文件中生成文档javadoc -d c:\mypath\home\html Lab1_1.java时,没有变量字段。 enter image description here

我的评论有什么问题?

1 个答案:

答案 0 :(得分:3)

Javadoc默认会忽略私有字段和方法。为它生成文档,并在命令行上传递-private参数。另请参阅Java Javadoc include Private