Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public inline class Vector {
- private final double x;
- private final double y;
- public Vector(double x, double y) {
- this.x = x;
- this.y = y;
- }
- public Vector add(Vector v) {
- return new Vector(x + v.x, y + v.y);
- }
- @Override
- public String toString() {
- return "{" + x + "," + y + "}";
- }
- }
- TEST:
- Instant start = Instant.now();
- Vector v = new Vector(0, 0);
- for (long i = 0; i < 5000000000L; i++) {
- v = v.add(v);
- }
- Instant end = Instant.now();
- Duration d = Duration.between(start,end);
- System.out.println(d + v.toString());
Advertisement
Add Comment
Please, Sign In to add comment