1
我想用Line2D
類創建線,但是當我跑我的課,我收到這樣的:創建Line2D對象
Linia:[email protected]。
這裏是我的代碼:
class linia {
public java.awt.geom.Line2D.Double getLine() {
return line;
}
public void setLine(java.awt.geom.Line2D.Double line) {
this.line = line;
}
private java.awt.geom.Line2D.Double line;
}
public class Lines {
public static java.awt.geom.Line2D.Double create(double x1, double y1, double x2, double y2) {
java.awt.geom.Line2D.Double tmpL = new java.awt.geom.Line2D.Double();
tmpL.x1 = x1;
tmpL.y1 = y1;
tmpL.x2 = x2;
tmpL.y2 = y2;
return tmpL;
}
public static void main(String[] args) {
linia line = new linia();
line.setLine(create(Double.valueOf(1), Double.valueOf(1), Double.valueOf(2), Double.valueOf(2)));
System.out.println("Line: " + line.getLine());
}
}
你是怎麼想到這個打印出來? – tkausl