Check out example codes for "vector2 java". It will help you in understanding the concepts better.

Code Example 1

public class Vector2 
{               
    // Members
    public float x;
    public float y;
        
    // Constructors
    public Vector2() {
        this.x = 0.0f;
        this.y = 0.0f;
    }
        
    public Vector2(float x, float y) {
        this.x = x;
        this.y = y;
    }
        
    // Compare two vectors
    public boolean equals(Vector2 other) {
        return (this.x == other.x && this.y == other.y);
    }
}

Learn ReactJs, React Native from akashmittal.com