1
我正在开发在Windows 7上使用NetBeans 7.3.1上的Java SE。我编写了以下代码。正在初始化java.awt.geom.Point2D
import java.awt.geom.Point2D;
static void setDisplayParams(Vector<Point2D> coords, double xMin, double xMax, double yMin, double yMax){
Point2D newCoords, oldCoords;
Vector<Point2D> displayCoords = new Vector<Point2D>();
for (int i=0; i<coords.size(); ++i){
oldCoords=coords.elementAt(i);
newCoords.setLocation(oldCoords.getX(), yMax-oldCoords.getY());
displayCoords.add(newCoords);
}
}
在生产线
newCoords.setLocation(oldCoords.getX(), yMax-oldCoords.getY());
我得到
variable newCoords might not have been initialzed
我Google
java.awt.geom.Point2D initializing java
和阅读here是
消息Point2D.Double()
应该初始化一个java.awt.geom.Point2D变量。然而newCoords没有字段Double。
我的for循环开始
for (int i=0; i<coords.size(); ++i){
newCoords=coords.elementAt(i);
newCoords.setLocation(newCoords.getX(), yMax-newCoords.getY());
displayParams.displayCoords.add(newCoords);
}
这并没有给我任何错误消息,但它在我不想做COORDS改变的值。
为了更好地提供帮助,请发布[SSCCE](http://sscce.org/)。 –