gpt4 book ai didi

java - 类的文档中没有变量

转载 作者:行者123 更新时间:2023-12-01 23:53:05 25 4
gpt4 key购买 nike

我有简单的类(class)

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

我的评论有什么问题吗?

最佳答案

Javadoc 默认情况下会忽略私有(private)字段和方法。为了使其生成文档,请在命令行上传递 -private 参数。另请参阅Java Javadoc include Private

关于java - 类的文档中没有变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16070742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com