gpt4 book ai didi

java - 异常: Requires 'start' < 'end'

转载 作者:行者123 更新时间:2023-12-02 07:13:24 25 4
gpt4 key购买 nike

我的 main 代码如下所示:

ArrayList<Integer> temper = new ArrayList<>();
ArrayList<Float> time = new ArrayList<>();
while(rs.next()){
time.add(rs.getFloat("Time_ms"));
temper.add(rs.getInt("VarValue"));
}
timemax = Collections.max(time);
timemin = Collections.min(time);
tempermax = Collections.max(temper);
tempermin = Collections.min(temper);

我还有这个创建图表的类:

public NormalDistributionDemo(final String title) {

super(title);
Function2D normal = new NormalDistributionFunction2D(2, 8);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normal,0, 5, 10, "Normal");
final JFreeChart chart = ChartFactory.createXYLineChart(
"AS Hellas Database",
"Date",
"Temperature",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
}

这段代码工作正常,但我想获取从数据库中提取的值并将它们插入到 x,y 轴中。

我这样做:

Function2D normal = new NormalDistributionFunction2D(tempermin, tempermax);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normal,timemin, timemax, 10,"Normal");

我收到此错误:

Exception in thread "main" java.lang.IllegalArgumentException: Requires 'start' < 'end'.
at org.jfree.data.general.DatasetUtilities.sampleFunction2DToSeries(DatasetUtilities.java:542)
at org.jfree.data.general.DatasetUtilities.sampleFunction2D(DatasetUtilities.java:511)
at org.jfree.chart.demo.NormalDistributionDemo.<init> (NormalDistributionDemo.java:80)
at org.jfree.chart.demo.NormalDistributionDemo.main(NormalDistributionDemo.java:71)

有什么想法吗?

最佳答案

来自sources :

public static XYSeries sampleFunction2DToSeries(Function2D f,
double start, double end, int samples, Comparable seriesKey) {

// some code

if (start >= end) {
throw new IllegalArgumentException("Requires 'start' < 'end'.");
}

// some code
}

这意味着,您传递的 timemin 少于或等于 timemax

关于java - 异常: Requires 'start' < 'end' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15243060/

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