0

I have this very simple class that looks like this:

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;
    }
}

Is it possible for me to do something like this in Java?

Vector2 amount = new Vector2(10, 40) * 2;

System.out.println(amount.x);  // Prints 20
System.out.println(amount.y);  // Prints 80
Get Off My Lawn
  • 34,175
  • 38
  • 176
  • 338

0 Answers0