Making Math vector implementation using java Below is the Code.

package Calculation;
public class Vector
{
    double x;
    double y;
    double z;
   /**Constructor to create a null vector i.e. 0i+0j+0k*/
    public Vector()
    {
        this.x=0;
        this.y=0;
        this.z=0;
    }
    /**Constructor to create a vector with the given values of i,j and k*/
    public Vector(double x,double y,double z)
    {
        this.x=x;
        this.y=y;
        this.z=z;
    }
    /**Return the string notation of the Vector */
    public String getCompleteStringNotation()
    {
        String not=this.x+"i^+"+this.y+"j^+"+this.z+"k^";
        return not;
    }
 /**Return the string notation of the Vector.Reduced it if any of x,y and z are integers */
    public String getReducedStringNotation()
    {
        String not="";
        if(this.x!=0)
        {
            if(this.x==(int)this.x)  
                not=not+(int)this.x+"i^+";
            else
                not=not+this.x+"i^+";
        }
        if(this.y!=0)
        {
            if(this.y==(int)this.y)
                not=not+(int)this.y+"j^+";
            else
                not=not+this.y+"j^+";
        }

        if(this.z!=0)
        {
            if(this.z==(int)this.z)
                not=not+(int)this.z+"k^";
            else
                not=not+this.z+"k^";
        }

            if(not.equals(""))
            return null;

            if(not.charAt(not.length()-1)=='+')
            not=not+"\b";

        return not;
    }
  /**Gives the length of the vector*/
    public double modulus()
    {
        double mod=Math.sqrt(Math.hypot(x,Math.hypot(y,z)));
        return mod;
    }
/**Check if two vectors are parallel or not*/
    public boolean isParallel(Vector v)
    {
        double xr=this.x/v.x;
        double yr=this.y/v.y;
        double zr=this.z/v.z;
        if(xr==yr&amp;&amp;yr==zr&amp;&amp;zr==xr)
            return true;
        else
            return false;
    }
  /**Returns the unit vector in the direction of the Calling vector object*/
    public Vector getUnitVector()
    {
        double mod=this.modulus();
        Vector unit=new Vector(this.x/mod,this.y/mod,this.z/mod);
        return unit;
    }
   /**Computes and return the dot product between two vector*/
    public double dotProduct(Vector v)
    {
        double res=this.x*v.x+this.y*v.y+this.z*v.z;
        return res;
    }
  /**Compute and returns the angle between two vectors in radians*/
    public double angleBetween(Vector v)
    {
        double dotPro=this.dotProduct(v);
        double modObj=this.modulus();
        double modV=v.modulus();
        double angle=Math.acos(dotPro/(modObj*modV));
        return angle;
    }
   /**Computes and returns the cross product of the two vector*/
    public Vector crossProduct(Vector v)
    {
        double resx=(this.y*v.z)-(v.y*this.z);
        double resy=-((this.x*v.z)-(v.x*this.z));
        double resz=(this.x*v.y)-(v.x*this.y);
        Vector res=new Vector(resx,resy,resz);
        return res; 
    }


}


And now some questions.


  1. In my stringNotation methods i could not write i cap.Mean to say i(and at the top of it ^) similarly with j and k.
  
  2. How to implement hashcode and equals function.
  
  3. Any other guide will also be entertained.
Question 1 not exactly the right place to ask here I think. Perhaps aks that one as a question on StackOverflow instead? For the i it's possible by directly putting in the î (type ^ first then i to make it 1 character, also works for ê û ô and â, not directly possible in standard character sets for j or k as far as I know).
Unless if you want to just use an alternative notation. For example printing (x,y,z) instead of the xî yj zk. But that would be trivial to implement yourself once you do decide to do it like that.



For question 2 I suggest you get yourself a good IDE (for example IntelliJ or Eclipse) and have it generate an equals and hashcode function for you. Doing that correctly can be tricky.



The code you have now looks pretty good as is.

The only big issue I have is the package visibility of the x y and z fields. The default best practice would be to make them private and provide getters to access them if needed. Also only provide setters if it makes sense to change the values (usually not the case).

Alternatively you might want to access the fields often in which case calling getters could become annoying. In that case I would suggest making the class immutable and provide public access the the fields.

public class Vector {
    public final double x;
    public final double y;
    public final double z;


Immutability is a nice property to have, especially if you want to use the class in a multithreaded environment. (Even if you make the fields private it's still a good idea to make them final as well).

A last smaller issue I want to mention is to always use braces to prevent silly mistakes. Especially if these silly mistakes can take hours to find.



lastly some minor nitpicks

the usual java convention says to put the opening bracket on the same line. For example:

 public String getReducedStringNotation() {
    String not="";
    if(this.x!=0) {
        if(this.x==(int)this.x) {  
            not=not+(int)this.x+"i^+";
        } else {
            not=not+this.x+"i^+";
        }
    }


The good thing is that you were consistent, so not really a complaint here.



You don't need this variable here:

public double modulus() {
    double mod=Math.sqrt(Math.hypot(x,Math.hypot(y,z)));
    return mod;
}


You can directly return it return Math.sqrt(Math.hypot(x,Math.hypot(y,z)))

Also, should this be

public double modulus() {
    return Math.sqrt(x*x + y*y + z*z);
}


instead?



The following line could also be a direct return statement:

    if(xr==yr&amp;&amp;yr==zr&amp;&amp;zr==xr)
        return true;
    else
        return false;


replace it with:

return xr==yr &amp;&amp; yr==zr &amp;&amp; zr==xr;




not the best variable name. I would prefer notation or result in most cases.

More specifically to actually understand what this does:

    if(not.equals(""))
    return null;


Which brings me to my last nitpick. Wouldn't it be better to return that empty string here? NullPointerExceptions are one of the most annoying thing to deal with in Java. I prefer some minor "huh?" moments when there was an empty string where I would expect a Vector over my program crashing with a NPE.