0

我有简单的课

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(); }
}
}

但是当我javadoc -d c:\mypath\home\html Lab1_1.java在 Lab1_1 html 文件中生成文档时,没有变量字段。在此处输入图像描述

我的评论有什么问题?

4

1 回答 1

3

Javadoc 默认会忽略私有字段和方法。为了使它为那些生成文档以及-private在命令行上传递参数。另请参阅Java Javadoc 包括 Private

于 2013-04-17T21:49:09.813 回答