我有这个非常简单的类,如下所示:
public class Vector2{
public final double x;
public final double y;
public Vector2(final double x, final double y){
this.x = x;
this.y = y;
}
}
我有可能在Java中做这样的事吗?
Vector2 amount = new Vector2(10, 40) * 2;
System.out.println(amount.x); // Prints 20
System.out.println(amount.y); // Prints 80